我正在使用jqwidgets 来绑定网格,如下所述:
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 格式的网格数据。