title: Using the 'jsonmap' property of jqGrid colModel with untyped JSON
body: <p>My AJAX-enabled WCF service returns JSON using this contract, </p>
  
  <pre><code>[DataContract]
  public class JQGridContract
  {
      [DataContract]
      public class Row
      {
          [DataMember]
          public int id { get; set; }
  
          [DataMember]
          public List&lt;string&gt; cell { get; set; }
  
          public Row()
          {
              cell = new List&lt;string&gt;();
          }
      }
  
      [DataMember]
      public int page { get; set; }
  
      [DataMember]
      public int total { get; set; }
  
      [DataMember]
      public int records { get; set; }
  
      [DataMember]
      public List&lt;Row&gt; rows { get; set; }
  
      public JQGridContract()
      {
          rows = new List&lt;Row&gt;();
      }
  }  
  </code></pre>
  
  <p>So each row of data in the results is untyped -- a row is essentially just a List without any column names attached. </p>
  
  <p>I think that makes it impossible for me to use the 'jsonmap' attribute of colModel? Basically I am retrieving a DataTable from the database, and then putting that DataTable into this JQGridContract form. Column information from the DataTable isnt contained in the json passed to the client, though.</p>
  
  <p>Id like to be able to map a column of my underlying DataTable to a column of my jqGrid, but without the need to strongly type my data contract. Is this possible? I thought it might be using anonymous types, where a list of anonymous objects (each anonymous object being a row) that have properties corresponding to each column in the underlying DataTable, but I haven't been able to make that work. </p>
  
  <p>Thanks. </p>
  
  <p>EDIT</p>
  
  <p>Here is an example of want I want to achieve (using server-side code, rather than javascript).</p>
  
  <p>Below is essentially a column model for a jqGrid thats done in c#:</p>
  
  <pre><code>            return new JQGridColumnCollection()
              {
                  new JQGridColumn()
                  {
                      DataField = "ID",     // maps to the DataTable
                      DataType = typeof(int),
                      HeaderText = "ID",
                      PrimaryKey = true,
                  },
                  new JQGridColumn()
                  {
                      DataField = "Name",  
                      DataType = typeof(string),
                      HeaderText = "Name"
                  },
                  new JQGridColumn()
                  {
                      DataField = "Birthdate",  
                      DataType = typeof(DateTime),
                      HeaderText = "Birth Date" 
                  }                
              };
  </code></pre>
  
  <p>The 'DataField' property of each column maps that column to a column in the underyling DataTable. The order of the columns in the DataTable could be different:</p>
  
  <pre><code>DataTable table = GetDataTable(" SELECT [Birthdate], [ID], [Name] From PersonTable "); 
  </code></pre>
  
  <p>But regardless of how I query my database, the grid will still show up where the first column is ID, the second column is Name, and the third column is Birthdate. I dont have to change my SQL query in order to change the order of the columns in my grid. </p>
  
  <p>I essentially want the equivalent of a DataField property in my client-side colModel for the jqGrid. That would require that my JSON columns are named, or that I can atleast map a jqGrid column to the numerical index of a column in the JSON data source. </p>