【问题标题】:JQGrid Reload ErrorJQGrid 重新加载错误
【发布时间】:2013-09-10 09:39:50
【问题描述】:

我是 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 + "\"}",
            }
        }

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

【问题讨论】:

  • 希望对您有所帮助jqgrid-reload-grid
  • Kishor,我已经尝试了提供的链接中提出的一些解决方案。但对我没有任何帮助。我们将不胜感激。

标签: jqgrid reload


【解决方案1】:

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

【讨论】:

  • 我已经实施了你的解决方案,但没有希望:(
  • 请给我一些解决方案:(
  • 出于测试目的,我添加了两个警报,一个在语句的开头,另一个在语句的结尾。两个警报都在触发,但是这个重新加载没有触发。它不会服务器端方法也用于调试目的。
猜你喜欢
  • 2011-09-11
  • 2011-11-07
  • 1970-01-01
  • 2015-04-03
  • 2011-10-27
  • 2011-04-16
  • 1970-01-01
  • 2016-11-17
  • 2012-01-30
相关资源
最近更新 更多