私はjqgridからのデータのみをエクスポートしたいと思います。Jqgrid postDataを取得
基本的に私は既にデータでバインドされたグリッドを持っており、後でBindGridModel(data)
と呼ぶことができ、クライアント側からのみサーバーに戻ることなくデータをバインドできるようにデータをjson文字列として取得したいとします。
データをjson文字列として取得する方法は後でデータとしてグリッドに与えることができますか?
これは私のグリッドの設定です:あなたはグリッドにバインドされたデータへのアクセス権を持っているloadCompleteイベントで
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
});
}
あなたが 'データ型を使用する必要があります。さらに、現在表示されているデータの1ページ分*をエクスポートするのか、すべてのデータをエクスポートしたいのかは不明です。さらに、あなたは "データをjson文字列として取得する"ことについて少し奇妙なことを書きました。通常、*オブジェクト*(グリッドの行からデータを表すアイテムの配列)としてデータを取得し、場合によってはサーバーに送信する必要がある場合にのみJSONに変換します。 – Oleg
グリッドスクリプトを動的に構築して、一部のページでデータを一度に読み込み、一部のページでデータを取得するためにサーバーポストを行うため、データパラメータについて心配する必要はありません。私は列名を使ってデータをエクスポートしたいので、データを追加して元に戻すことができます。最初の25レコードを取得した後、次のページをクリックすると、この25レコードをどこかに保存します。私は最初の25にそれらを追加し、50のレコードを表示したい、私は内蔵のページャーでそれを行う方法があるかどうかを見たいと思っています。 –