JQGrid重载错误

时间:2013-09-10 09:39:50

标签: jqgrid reload

我是JqGrid的新手。我有重新加载JqGrid的问题。没有任何错误。

jQuery("#gridData").jqGrid("setGridParam",
                           { type: "POST",
                             url: "TablesCoolView.aspx/GetTableData",
                             data: "{TableName :'" + "Test" + "'}",
                             contentType: "application/json",
                             dataType: "json" 
                           }).trigger("reloadGrid", [{ current: true }]);

守则将在这里,

onPaging: function (pgButton) {
                    //debugger;

                var pagerId = this.p.pager.substr(1); // get paper id like "pager"
                var currentPage = jQuery("#gridData").jqGrid("getGridParam", 'page');   //get current  page 
                var lastPage = jQuery("#gridData").jqGrid("getGridParam", 'lastpage');  //get last page 

            if (currentPage - 1 == lastPage - 1)
                jQuery("#gridData").jqGrid("setGridParam", { page: lastPage }).trigger("reloadGrid");  // set the requested page to the last page value – then reload 

            var currentRecordCount = jQuery("#gridData").jqGrid("getGridParam", 'reccount');  //get the record count
            var recordsPerPage = jQuery("#gridData").jqGrid("getGridParam", 'rowNum');       // get the records per page
            var newValue = 0;  // new value
            if (pgButton === "user") {
                newValue = $(".ui-pg-input").val(); 
            }
            else {

                if (pgButton.indexOf("next") >= 0)
                    newValue = ++currentPage;
                else if (pgButton.indexOf("prev") >= 0)
                    newValue = --currentPage;
                else if (pgButton.indexOf("last") >= 0)
                    newValue = jQuery("#gridId").jqGrid("getGridParam", 'lastpage');
                else if (pgButton.indexOf("first") >= 0)
                    newValue = 1;
            }
            alert(pgButton);
                //alert(newValue);
                jQuery("#gridData").jqGrid("setGridParam", { page: newValue }).trigger("reloadGrid");  // set the requested page to the last page value – then reload
                currentRecordCount = jQuery("#gridData").jqGrid("getGridParam", 'reccount');          // read the current page records
                //alert('RecordCount: ' + currentRecordCount + ' RecordsPerPage: ' + recordsPerPage);

            if (currentRecordCount < recordsPerPage) {
                startRange = 1;
                endRange += endRange;

                alert("Grid Reload test Start");
                //jQuery("#gridData").jqGrid("setGridParam", { type: "POST", url: "TablesCoolView.aspx/GetTableData", page: 1, async: true, loadOnce: true, data: "{TableName :'" + "Test" + "'}", contentType: "application/json", dataType: "json" }).trigger("reloadGrid");
                jQuery("#gridData").jqGrid("setGridParam", { type: "POST", url: "TablesCoolView.aspx/GetTableData", data: "{TableName :'" + "Test" + "'}", contentType: "application/json", dataType: "json" }).trigger("reloadGrid", [{ current: true }]);

                alert("Grid Reload test End");
                //jQuery("#gridData").jqGrid("setGridParam", { datatype: "json", data: "{TableName :'" + tableName + "', \"PageSize\" :\"" + recordsPerPage + "\", \"PageNumber\" :\"" + newValue + "\"}", url: "TablesCoolView.aspx/GetNextSetOfRecords" }).trigger("reloadGrid");
                //data: "{TableName :'" + tableName + "', \"PageSize\" :\"" + recordsPerPage + "\", \"PageNumber\" :\"" + newValue + "\"}",
            }
        }

不知道哪里出错了。 请帮我解决这个问题。

1 个答案:

答案 0 :(得分:1)

尝试将data: "{TableName :'" + "Test" + "'}",更改为postData: "{TableName :'" + "Test" + "'}",