Lalita
Lalita

Reputation: 163

JQGrid Reload Error

I am new to JqGrid. I have a problem with reload JqGrid. Not getting any errors also.

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

The Code will go here,

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

Dont know where am doing wrong. Please help me out of this.

Upvotes: 0

Views: 755

Answers (1)

Kris
Kris

Reputation: 1902

Try changing data: "{TableName :'" + "Test" + "'}", to postData: "{TableName :'" + "Test" + "'}",

Upvotes: 1

Related Questions