带有大量网格的JqGrid分页

时间:2015-03-16 14:35:39

标签: jqgrid paging

我有一个单页的ASP.Net Web表单应用程序。还有很多网格。在我的应用程序中,有一些隐藏或显示网格的链接。问题是,当我启动应用程序时,显示的网格的分页工作正常。 (我试过每个网格)。但是,当我单击链接隐藏网格并显示另一个网格时,分页不起作用。网格初始化是;

    $('#tblApplicationSettings').jqGrid({
        url: cms.util.getAjaxPage(),
        cellLayout: cms.theme.list.cellLayout,
        hoverrows: false,
        forceFit: true,
        jsonReader: {
            root: "rows",
            page: "page",
            total: "total",
            records: "records",
            repeatitems: false,
            cell: "",
            id: "0"
        },
        width: 900,
        height: 400,
        datatype: 'local',
        colNames: ['SettingId',
                    'Description',
                    'Name',
                    'Value',
                    'ServerId',
                    'IsReadOnly',
                    ''
        ],
        colModel: [
            {
                name: 'SettingId',
                index: 'SettingId',
                hidden: true
            },
            {
                name: 'Description',
                index: 'Description',
                search: false,
                editable: true,
                sortable: false,
                width: 150,
                inlineEditable: true
            },
            {
                name: 'Name',
                index: 'Name',
                search: false,
                editable: false,
                sortable: false,
                width: 150,
                inlineEditable: false
            },
            {
                name: 'Value',
                index: 'Value',
                search: false,
                editable: true,
                sortable: false,
                width: 250,
                inlineEditable: true,
            },
            {
                name: 'ServerId',
                index: 'ServerId',
                search: false,
                editable: true,
                sortable: false,
                width: 150,
                formatter: 'select',
                edittype: 'select',
                editoptions: {
                    value: options,
                },
                inlineEditable: true
            },
            {
                name: 'IsReadOnly',
                index: 'IsReadOnly',
                hidden: true
            },
            {
                name: 'JsUsage',
                index: 'JsUsage',
                search: false,
                editable: true,
                sortable: false,
                width: 150,
                inlineEditable: true
            },
        ],
        onSelectRow: function (id) {
            if (id && id !== lastSelection) {
                jQuery('#grid').jqGrid('restoreRow', lastSelection);
                lastSelection = id;
            }

            var columnModel = $('#grid').getGridParam('colModel');
            var colNames = new Array();

            $.each(columnModel, function (index, column) {

                colNames.push(column.name);

                if (isReadOnly || !column.inlineEditable) {
                    column.editable = false;
                }
                else {
                    column.editable = true;
                }

                if (column.edittype == "select") {
                    column.editoptions.dataEvents = [{
                        type: 'change',
                        fn: function (e) {
                            var newServerId = $(this).val();
                            that.isServerIdChanged = true;
                            if (newServerId == "null") {
                                                            }
                        }
                    }]
                }
            });

            var row = $('#grid').getRowData(id);
            var isReadOnly = row.IsReadOnly == "true" ? true : false;

            if (isReadOnly) {
                alert("row is not editable");
return null;
            }

            jQuery("#grid").jqGrid('editRow', id, {
                keys: true,
                extraparam: {
                    dataType: 'updateSetting',
                    colNames: JSON.stringify(colNames),
                    settingName: row.Name,
                    settingId: row.SettingId
                },
                successfunc: function (result) {
                    $("#grid").trigger('reloadGrid');
                }
            });
        },
        editurl: '/Ajax.ashx',
        rowNum: 25,
        direction: "ltr",
        scroll: 1,
        gridview: true,
        pager: '#divPager',
        viewrecords: true,
    });

    $('#grid').setGridParam({ datatype: "json", postData: { dataType: 'getSettings' } });

    $('#grid').jqGrid('navGrid', '#divPager', { edit: false, add: false, del: false, search: false, refresh: false });

    $('#grid').trigger('reloadGrid');
对所有网格都这样。我需要提示或帮助。感谢。

0 个答案:

没有答案