0
我使用jqwidgets到網格綁定類似下面:如何使用jquery綁定與未知字段的網格?
var url = "sampledata/customers.xml";
var parentsLength = $("#jqxWidget").parents().length;
if (parentsLength > 3) {
url = 'sampledata/customers.xml';
}
// prepare the data
var source = {
datatype: "xml",
datafields: [
{ name: 'CompanyName', map: 'm\\:properties>d\\:CompanyName' },
{ name: 'ContactName', map: 'm\\:properties>d\\:ContactName' },
{ name: 'ContactTitle', map: 'm\\:properties>d\\:ContactTitle' },
{ name: 'City', map: 'm\\:properties>d\\:City' },
{ name: 'PostalCode', map: 'm\\:properties>d\\:PostalCode' },
{ name: 'Country', map: 'm\\:properties>d\\:Country' }
],
root: "entry",
record: "content",
id: 'm\\:properties>d\\:CustomerID',
url: url
};
// Create jqxGrid
$("#jqxgrid").jqxGrid(
{
width: 670,
source: source,
theme: theme,
columnsresize: true,
columns: [
{ text: 'Company Name', datafield: 'CompanyName', width: 250 },
{ text: 'Contact Name', datafield: 'ContactName', width: 150 },
{ text: 'Contact Title', datafield: 'ContactTitle', width: 180 },
{ text: 'City', datafield: 'City', width: 120 },
{ text: 'Postal Code', datafield: 'PostalCode', width: 90 },
{ text: 'Country', datafield: 'Country', width: 100 }
]
});
但現在我有與它未知的行和列動態網格。我如何綁定?我正在調用Web服務來獲取XML格式的網格數據。