jqgrid json对象分页&寻找不工作 [英] jqgrid json object paging & searching not working

查看:150
本文介绍了jqgrid json对象分页&寻找不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我正在使用jqgrid和json object.i'm获取数据但是分页和搜索无法正常工作..当我点击下一页时出现相同的数据并且在搜索中也是如此... plzzz帮助我。

我的整个jqGrid,供参考:



Hi i'm using jqgrid and json object.i'm getting the data but paging and search not working..means when i click on next page same data is appearing and in search too..plzzz help me.
my entire jqGrid, for reference:

 $(document).ready(function () {
     var numberTemplate = { formatter: 'number', align: 'center', sorttype: 'number' };
     jQuery("#UsersGrid").jqGrid({
        url: 'Jqg.aspx/GetDataTable',
        datatype: 'json',
        mtype: 'GET',
        ajaxGridOptions: { contentType: "application/json",
            success: function (data, textStatus) {
                if (textStatus == "success") {
                    var thegrid = $("#UsersGrid")[0];
                    thegrid.addJSONData(data.d);
                    thegrid.grid.hDiv.loading = false; alert('success');
                    switch (thegrid.p.loadui) {
                        case "disable":
                            break;
                        case "enable":
                            $("#load_" + thegrid.p.id).hide();
                            break;
                        case "block":
                            $("#lui_" + thegrid.p.id).hide();
                            $("#load_" + thegrid.p.id).hide();
                            break;
                    }
                }
            },
            error: alert('failed')
        },

        postData: {
            FilePath: function () {
                return $("#FilePath").text();
            },
            Filter: function () {
                return $("#Filter").text();
            },
            submenu: function () {
                return $("#lblSubmenu").text();
            }
        },
        mtype: 'POST',
        colNames: ['Sr_No', 'Errors', 'File Name', 'Date', 'action'],
        colModel: [{ name: 'Sr_No', index: 'Sr_No', key: true, width: 100, align: 'center', sortable: true, sorttype: 'integer', searchtype: "integer", searchrules: { "required": true, "number": true, "maxValue": 13} },
               { name: 'Errors', index: 'Errors', width: 100, align: 'center', search: true, sorttype: "int", sortable: true },
               { name: 'File Name', index: 'files', search: true, stype: 'text', width: 500, sorttype: "string", align: 'center', sortable: true },
               { name: 'Date', index: 'Date', width: 100, search: true, sortable: true, sorttype: "date", align: 'center', sorttype: 'date',
                   formatter: 'date', formatoptions: { newformat: 'M-d-Y' }, datefmt: 'M-d-Y'
               },
               { name: 'action', index: 'action', align: 'center', sortable: false, search: false, formatter: displayButtons}],
        pager: '#UsersGridPager',
        viewrecords: true,
        imgpath: 'Images/jqgrid',
        rowNum: 5,
        rowList: [5, 10, 20],
        gridview: true,
        loadonce: false,
        rownumbers: false,
        sortname: 'Sr_No',
        sortorder: 'desc',
        localReader: { id: 'Sr_No' },
        editurl: 'clientArray',
        clickOnPagination : function() { $(this).jqGrid("clearGridData"); $(this).setGridParam({datatype: 'json'}).triggerHandler("reloadGrid"); },
        cmTemplate: {
            searchoptions: {
                sopt: ['cn', 'eq', 'ne']//comment out this out tp resolve error
            },
            searchrules: {
                required: true
            }
        },
        height: '100%',
        serializeGridData: function (postData) {
            var propertyName, propertyValue, dataToSend = {};
            for (propertyName in postData) {
                if (postData.hasOwnProperty(propertyName)) {
                    propertyValue = postData[propertyName];
                    if ($.isFunction(propertyValue)) {
                        dataToSend[propertyName] = propertyValue();
                    } else {
                        dataToSend[propertyName] = propertyValue
                    }
                }
            }

            return JSON.stringify(dataToSend);
        }
    });
    jQuery("#UsersGrid").navGrid('#UsersGridPager',
    { add: false, edit: false, del: false, refresh: false },
    {},
    {},
    {},
    { multipleSearch: true, multipleGroup: true, afterRedraw: function () {
        $(this).find(".input-elm").triggerHandler('change', [true]);
    }
    });
    function displayButtons(cellvalue, options, rowObject) {
        var View = "<a href="#" target="_blank">View</a>";
        var Download = "<a href="/Download/" target="_blank">Download</a>";
        return View + Download;
    }
});

推荐答案

(document).ready(function(){
var numberTemplate = {formatter:'number ',align:'center',sorttype:'number'};
jQuery(#UsersGrid)。jqGrid({
url:'Jqg.aspx / GetDataTable',
datatype: 'json',
mtype:'GET',
ajaxGridOptions:{contentType:application / json,
success:function(data,textStatus){
if(textStatus = =成功){
var thegrid =
(document).ready(function () { var numberTemplate = { formatter: 'number', align: 'center', sorttype: 'number' }; jQuery("#UsersGrid").jqGrid({ url: 'Jqg.aspx/GetDataTable', datatype: 'json', mtype: 'GET', ajaxGridOptions: { contentType: "application/json", success: function (data, textStatus) { if (textStatus == "success") { var thegrid =


(#UsersGrid)[0];
thegrid.addJSONData(data.d);
thegrid.grid.hDiv.loading = false; alert('success');
switch(thegrid.p.loadui){
casedisable:
break;
caseenable:
("#UsersGrid")[0]; thegrid.addJSONData(data.d); thegrid.grid.hDiv.loading = false; alert('success'); switch (thegrid.p.loadui) { case "disable": break; case "enable":


(#load_+ thegrid.p.id).hide();
break;
caseblock:
("#load_" + thegrid.p.id).hide(); break; case "block":


这篇关于jqgrid json对象分页&amp;寻找不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆