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.
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 DataTable
from the service.
I am not sure how to bind the data in jqGrid.
Please anyone give your input.
My sample DataTable
which is returned from WCF Service
<DataTable xmlns="http://schemas.datacontract.org/2004/07/System.Data">
<xs:schema id="NewDataSet" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="LTC" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="LTC">
<xs:complexType>
<xs:sequence>
<xs:element name="vc_longtermcondition" type="xs:string" minOccurs="0"/>
<xs:element name="vc_longtermconditionid" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<DocumentElement xmlns="">
<LTC diffgr:id="LTC1" msdata:rowOrder="0" diffgr:hasChanges="inserted">
<vc_longtermcondition>Asthma</vc_longtermcondition>
<vc_longtermconditionid>91c0c30c-816e-e111-a207-005056a50018</vc_longtermconditionid>
</LTC>
<LTC diffgr:id="LTC2" msdata:rowOrder="1" diffgr:hasChanges="inserted">
<vc_longtermcondition>Chronic Heart Failure</vc_longtermcondition>
<vc_longtermconditionid>dbe68618-816e-e111-a207-005056a50018</vc_longtermconditionid>
</LTC>
<LTC diffgr:id="LTC3" msdata:rowOrder="2" diffgr:hasChanges="inserted">
<vc_longtermcondition>CKD</vc_longtermcondition>
<vc_longtermconditionid>
dde68618-816e-e111-a207-005056a50018
</vc_longtermconditionid>
</LTC>
<LTC diffgr:id="LTC4" msdata:rowOrder="3" diffgr:hasChanges="inserted">
<vc_longtermcondition>
COPD
</vc_longtermcondition>
<vc_longtermconditionid>
e94f4222-816e-e111-a207-005056a50018
</vc_longtermconditionid>
</LTC>
<LTC diffgr:id="LTC5" msdata:rowOrder="4" diffgr:hasChanges="inserted">
<vc_longtermcondition>
Diabetes Type 1
</vc_longtermcondition>
<vc_longtermconditionid>
e1b54c29-816e-e111-a207-005056a50018
</vc_longtermconditionid>
</LTC>
<LTC diffgr:id="LTC6" msdata:rowOrder="5" diffgr:hasChanges="inserted">
<vc_longtermcondition>
Diabetes Type 2
</vc_longtermcondition>
<vc_longtermconditionid>
2b86ad32-816e-e111-a207-005056a50018
</vc_longtermconditionid>
</LTC>
<LTC diffgr:id="LTC7" msdata:rowOrder="6" diffgr:hasChanges="inserted">
<vc_longtermcondition>
Hypertension
</vc_longtermcondition>
<vc_longtermconditionid>
d1d7c339-816e-e111-a207-005056a50018
</vc_longtermconditionid>
</LTC>
<LTC diffgr:id="LTC8" msdata:rowOrder="7" diffgr:hasChanges="inserted">
<vc_longtermcondition>
LTC10
</vc_longtermcondition>
<vc_longtermconditionid>
df1dbcd1-c977-e111-ac35-005056a50018
</vc_longtermconditionid>
</LTC>
<LTC diffgr:id="LTC9" msdata:rowOrder="8" diffgr:hasChanges="inserted">
<vc_longtermcondition>
LTC11
</vc_longtermcondition>
<vc_longtermconditionid>
40f5deda-c977-e111-ac35-005056a50018
</vc_longtermconditionid>
</LTC>
<LTC diffgr:id="LTC10" msdata:rowOrder="9" diffgr:hasChanges="inserted">
<vc_longtermcondition>
LTC12
</vc_longtermcondition>
<vc_longtermconditionid>
42f5deda-c977-e111-ac35-005056a50018
</vc_longtermconditionid>
</LTC>
<LTC diffgr:id="LTC11" msdata:rowOrder="10" diffgr:hasChanges="inserted">
<vc_longtermcondition>
LTC8
</vc_longtermcondition>
<vc_longtermconditionid>
fe5e3ecb-c977-e111-ac35-005056a50018
</vc_longtermconditionid>
</LTC>
<LTC diffgr:id="LTC12" msdata:rowOrder="11" diffgr:hasChanges="inserted">
<vc_longtermcondition>
LTC9
</vc_longtermcondition>
<vc_longtermconditionid>
005f3ecb-c977-e111-ac35-005056a50018
</vc_longtermconditionid>
</LTC>
</DocumentElement>
</diffgr:diffgram>
</DataTable>
Here vc_longtermcondition will be the ColumnHeader(Asthma,Diabetes,COPD) and vc_longtermconditionid will the cell value respective to the columnheader
MySampleGrid will be like this
id ----------- Asthma -------------------------ChronicHeartFailure------------------
1. 91c0c30c-816e-e111-a207-005056a50018 dbe68618-816e-e111-a207-005056a50018