Flexigrid適用於任何JSON格式或XML格式。 對於這兩種類型,它們都必須採用特定的格式。
XML格式必須是完全一樣的:
<rows>
<page>1</page>
<total>2</total>
<row id="reg1">
<cell>reg1-cell1</cell>
<cell>reg1-cell2</cell>
</row>
<row id="reg2">
<cell>reg2-cell1</cell>
<cell>reg2-cell2</cell>
</row>
</rows>
在你的服務器端,你必須解析原始的XML文件並重新產生這種特定的XML格式。
關於排序問題: 點擊其中一列後,flexigrid發送幾個參數如下定義網址:
$("#flex1").flexigrid({
url: 'staff.php'
});
它發送排序列,順序等等。在服務器端,您將獲取傳遞的參數以對行進行重新排序。
請查閱Documentation頁面瞭解更多信息。
更新:假設您有一個包含數據的數組(Customers)。在這種情況下,我們將創建一個對象,將認爲您的數據,但以JSON格式如下:
function formatCustomerResults(Customers){
var rows = Array();
for (i = 0; i < Customers.length; i++) {
var item = Customers[i];
rows.push({ cell: [item.CustomerId,
item.Name,
item.Phone,
item.Address]
});
}
return {
total: Customers.length,
page: 1,
rows: rows
};
}`
然後你會打電話給你的函數:
$("#FlexTable").flexAddData(formatCustomerResults(eval(data)));
什麼編程語言使用? – Anwar 2012-01-28 15:02:25
@Anwar我使用jQuery – pilettoturtle 2012-01-28 15:22:00
除了使用jQuery,我的意思是你的服務器端語言? – Anwar 2012-01-28 16:46:38