title: How to Dynamically add Column and Row Header and based on the Row and Column value how to bind Data in jqGrid?
body: <p>I need to dynamically render the jqGrid. I am using WCF Rest service to get the Data from the CRM Database. As far as i have statically gave the Column header in column name and column model will bind the data.</p>
  
  <p>Now my requirement is Column header and Row Header needs to be generated dynamically.
  Based on the column and row value each cell value has to be shown.
  I am sending the data as <code>DataTable</code> from the service.
  I am not sure how to bind the data in jqGrid.</p>
  
  <p>Please anyone give your input. </p>
  
  <p>My sample <code>DataTable</code> which is returned from WCF Service</p>
  
  <pre class="lang-js prettyprint-override"><code>&lt;DataTable xmlns="http://schemas.datacontract.org/2004/07/System.Data"&gt;
    &lt;xs:schema id="NewDataSet" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"&gt;
      &lt;xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="LTC" msdata:UseCurrentLocale="true"&gt;
        &lt;xs:complexType&gt;
          &lt;xs:choice minOccurs="0" maxOccurs="unbounded"&gt;
            &lt;xs:element name="LTC"&gt;
              &lt;xs:complexType&gt;
                &lt;xs:sequence&gt;
                  &lt;xs:element name="vc_longtermcondition" type="xs:string" minOccurs="0"/&gt;
                  &lt;xs:element name="vc_longtermconditionid" type="xs:string" minOccurs="0"/&gt;
                &lt;/xs:sequence&gt;
              &lt;/xs:complexType&gt;
            &lt;/xs:element&gt;
          &lt;/xs:choice&gt;
        &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
    &lt;/xs:schema&gt;
    &lt;diffgr:diffgram xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"&gt;
      &lt;DocumentElement xmlns=""&gt;
        &lt;LTC diffgr:id="LTC1" msdata:rowOrder="0" diffgr:hasChanges="inserted"&gt;
          &lt;vc_longtermcondition&gt;Asthma&lt;/vc_longtermcondition&gt;
          &lt;vc_longtermconditionid&gt;91c0c30c-816e-e111-a207-005056a50018&lt;/vc_longtermconditionid&gt;
        &lt;/LTC&gt;
        &lt;LTC diffgr:id="LTC2" msdata:rowOrder="1" diffgr:hasChanges="inserted"&gt;
          &lt;vc_longtermcondition&gt;Chronic Heart Failure&lt;/vc_longtermcondition&gt;
          &lt;vc_longtermconditionid&gt;dbe68618-816e-e111-a207-005056a50018&lt;/vc_longtermconditionid&gt;
        &lt;/LTC&gt;
        &lt;LTC diffgr:id="LTC3" msdata:rowOrder="2" diffgr:hasChanges="inserted"&gt;
          &lt;vc_longtermcondition&gt;CKD&lt;/vc_longtermcondition&gt;
          &lt;vc_longtermconditionid&gt;
            dde68618-816e-e111-a207-005056a50018
          &lt;/vc_longtermconditionid&gt;
        &lt;/LTC&gt;
        &lt;LTC diffgr:id="LTC4" msdata:rowOrder="3" diffgr:hasChanges="inserted"&gt;
          &lt;vc_longtermcondition&gt;
            COPD
          &lt;/vc_longtermcondition&gt;
          &lt;vc_longtermconditionid&gt;
            e94f4222-816e-e111-a207-005056a50018
          &lt;/vc_longtermconditionid&gt;
        &lt;/LTC&gt;
        &lt;LTC diffgr:id="LTC5" msdata:rowOrder="4" diffgr:hasChanges="inserted"&gt;
          &lt;vc_longtermcondition&gt;
            Diabetes Type 1
          &lt;/vc_longtermcondition&gt;
          &lt;vc_longtermconditionid&gt;
            e1b54c29-816e-e111-a207-005056a50018
          &lt;/vc_longtermconditionid&gt;
        &lt;/LTC&gt;
        &lt;LTC diffgr:id="LTC6" msdata:rowOrder="5" diffgr:hasChanges="inserted"&gt;
          &lt;vc_longtermcondition&gt;
            Diabetes Type 2
          &lt;/vc_longtermcondition&gt;
          &lt;vc_longtermconditionid&gt;
            2b86ad32-816e-e111-a207-005056a50018
          &lt;/vc_longtermconditionid&gt;
        &lt;/LTC&gt;
        &lt;LTC diffgr:id="LTC7" msdata:rowOrder="6" diffgr:hasChanges="inserted"&gt;
          &lt;vc_longtermcondition&gt;
            Hypertension
          &lt;/vc_longtermcondition&gt;
          &lt;vc_longtermconditionid&gt;
            d1d7c339-816e-e111-a207-005056a50018
          &lt;/vc_longtermconditionid&gt;
        &lt;/LTC&gt;
        &lt;LTC diffgr:id="LTC8" msdata:rowOrder="7" diffgr:hasChanges="inserted"&gt;
          &lt;vc_longtermcondition&gt;
            LTC10
          &lt;/vc_longtermcondition&gt;
          &lt;vc_longtermconditionid&gt;
            df1dbcd1-c977-e111-ac35-005056a50018
          &lt;/vc_longtermconditionid&gt;
        &lt;/LTC&gt;
        &lt;LTC diffgr:id="LTC9" msdata:rowOrder="8" diffgr:hasChanges="inserted"&gt;
          &lt;vc_longtermcondition&gt;
            LTC11
          &lt;/vc_longtermcondition&gt;
          &lt;vc_longtermconditionid&gt;
            40f5deda-c977-e111-ac35-005056a50018
          &lt;/vc_longtermconditionid&gt;
        &lt;/LTC&gt;
        &lt;LTC diffgr:id="LTC10" msdata:rowOrder="9" diffgr:hasChanges="inserted"&gt;
          &lt;vc_longtermcondition&gt;
            LTC12
          &lt;/vc_longtermcondition&gt;
          &lt;vc_longtermconditionid&gt;
            42f5deda-c977-e111-ac35-005056a50018
          &lt;/vc_longtermconditionid&gt;
        &lt;/LTC&gt;
        &lt;LTC diffgr:id="LTC11" msdata:rowOrder="10" diffgr:hasChanges="inserted"&gt;
          &lt;vc_longtermcondition&gt;
            LTC8
          &lt;/vc_longtermcondition&gt;
          &lt;vc_longtermconditionid&gt;
            fe5e3ecb-c977-e111-ac35-005056a50018
          &lt;/vc_longtermconditionid&gt;
        &lt;/LTC&gt;
        &lt;LTC diffgr:id="LTC12" msdata:rowOrder="11" diffgr:hasChanges="inserted"&gt;
          &lt;vc_longtermcondition&gt;
            LTC9
          &lt;/vc_longtermcondition&gt;
          &lt;vc_longtermconditionid&gt;
            005f3ecb-c977-e111-ac35-005056a50018
          &lt;/vc_longtermconditionid&gt;
        &lt;/LTC&gt;
      &lt;/DocumentElement&gt;
    &lt;/diffgr:diffgram&gt;
  &lt;/DataTable&gt;
  </code></pre>
  
  <p>Here vc_longtermcondition will be the ColumnHeader(Asthma,Diabetes,COPD)
  and vc_longtermconditionid will the cell value respective to the columnheader</p>
  
  <p>MySampleGrid will be like this</p>
  
  <pre class="lang-none prettyprint-override"><code>id ----------- Asthma -------------------------ChronicHeartFailure------------------
  1.    91c0c30c-816e-e111-a207-005056a50018     dbe68618-816e-e111-a207-005056a50018 
  </code></pre>