首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Jqgrid获取postData

Jqgrid获取postData
EN

Stack Overflow用户
提问于 2012-05-10 01:14:14
回答 1查看 3.4K关注 0票数 0

我只想从jqgrid导出数据。

所以基本上我已经有了一个绑定了数据的网格,我想以json字符串的形式获取数据,这样我以后就可以调用BindGridModel(data)并绑定数据,而不需要只从客户端返回到服务器。

这是我的网格配置:

代码语言:javascript
复制
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
    });
}
EN

回答 1

Stack Overflow用户

发布于 2012-05-10 02:05:04

loadComplete事件中,您可以访问绑定到网格的数据,并且可以对其进行字符串化。我通常将其设置为Jquery数据属性,这样我就可以在事件之外访问它。

代码语言:javascript
复制
loadComplete: function(data) {
    $('#gridid').data('jqdata', data);//JSON stringify the data 1st if you need to
},

然后,您可以稍后通过以下方式访问该数据:

代码语言:javascript
复制
$('#gridid').data('jqdata');
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10520912

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档