我想從jqgrid只導出數據。Jqgrid獲取postData
所以基本上我已經有了一個綁定的數據網格,我想以json字符串的形式獲取數據,因此我可以稍後調用BindGridModel(data)
並綁定數據,而無需從客戶端返回到服務器。
我怎樣才能得到數據作爲json字符串,所以後來我可以把它作爲數據給網格?
這是我的網格配置:
function BindGridModel(data) {
$('#jqgInventory').jqGrid({
autowidth: true,
caption: 'Inventory',
datatype: 'json',
forceFit: true,
gridview: true,
height: 500,
hidegrid: false,
ignoreCase: true,
loadui: 'disable',
pager: '#pager',
mtype: 'post',
rowNum: 25,
shrinkToFit: true,
url: '/MCI/Inventory/Inventory/GetIndexGridData',
viewrecords: true,
postData: {
modelView: JSON.stringify(model),
__RequestVerificationToken: $('[name="__RequestVerificationToken"]').val()
},
beforeRequest: function() {
$('#gridScript').block();
},
beforeSelectRow: function(rowid, e) {
return false;
},
gridComplete: function() {
$('#lblVehicleCount').html($('#jqgInventory').getGridParam('records'));
$('#gridScript').unblock();
Inventory.modifyGridCellClick();
},
colModel: [
{
align: 'center',
name: 'Select',
label: 'SEL',
title: true,
width: 20,
index: 'Select'},
{
align: 'left',
name: 'Photo',
hidden: false,
label: 'PHOTO',
stype: 'text',
sortable: false,
sorttype: 'text',
title: true,
width: 100,
index: 'Photo'},
{
align: 'left',
name: 'Information',
hidden: false,
label: 'INFO',
stype: 'text',
sortable: false,
sorttype: 'text',
title: true,
width: 100,
index: 'Information'},
{
align: 'right',
name: 'Price',
hidden: false,
label: 'PRICE',
stype: 'text',
sortable: true,
sorttype: function(cellValue) {
return CustomGridSortByIntegerAsString(cellValue);
},
title: true,
width: 50,
index: 'Price'},
{
align: 'right',
name: 'Mileage',
hidden: false,
label: 'MILEAGE',
stype: 'text',
sortable: true,
sorttype: function(cellValue) {
return CustomGridSortByIntegerAsString(cellValue);
},
title: true,
width: 25,
index: 'Mileage'},
{
align: 'right',
name: 'Age',
hidden: false,
label: 'AGE',
stype: 'text',
sortable: true,
sorttype: function(cellValue) {
return CustomGridSortByIntegerAsString(cellValue);
},
title: true,
width: 50,
index: 'Age'},
{
name: 'VehicleKey',
hidden: true,
label: 'VEHICLEKEY',
width: 50,
index: 'VehicleKey'}
],
data: data
});
}
: 'local''而不是'數據類型:' json'' 。此外,您是否想要導出當前顯示的一頁數據或者是否要導出所有數據尚不清楚。此外,你寫了「將數據作爲json字符串」,這有點奇怪。通常情況下,只有在需要將數據發送到服務器時,纔會將數據作爲* object *(表示網格行數據的項目數組)獲取並在某些情況下將其轉換爲JSON。 – Oleg
不要擔心數據參數,因爲我正在動態地構建網格腳本,因此一些頁面會立即加載數據,其中一些頁面會執行服務器發佈以獲取數據。我想導出帶有列名的數據,這樣我就可以添加更多的數據並將其綁定回來,我正在做類似獲取前25條記錄,然後當你點擊下一頁時,我將這25條記錄存儲在某處並在我的路上在抓取下一個25後回來,我想將它們添加到前25個,並顯示50條記錄,我試圖看看是否有內置尋呼機的方式。 –