我想从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条记录,我试图看看是否有内置寻呼机的方式。 –