2011-03-03 35 views
0

這是我嘗試在json中導出我的網格數據的javascript代碼。它拋出一個異常,我不明白爲什麼。當我下載了jqgrid我檢查了導入/導出模塊。 我想在隱藏字段中插入json以獲取服務器端的數據進行驗證和保存。對象unidentify使用jqgrid.jqGridExport()時,如何使用它導出json中的網格

$('#proveObjekt2').val(JSON.stringify($("#rowed5").jqGridExport("jsonstring"))); 
... 
<asp:HiddenField ID="proveObjekt2" runat="server" /> 

回答

0

您以錯誤的形式使用參數jqGridExport。參數必須是具有三種可能屬性的對象:exptype,rootident。因爲參數的默認值是

{ 
    exptype : "xmlstring", 
    root: "grid", 
    ident: "\t" 
} 

呼叫$("#rowed5").jqGridExport("jsonstring")返回XML而不是JSON。您應該使用

jQuery("#rowed5").jqGridExport({exptype:"jsonstring"}) 

jQuery("#rowed5").jqGrid('jqGridExport',{exptype:"jsonstring"}) 

代替。

相關問題