Carmen Fang
Carmen Fang

Reputation: 11

How could I know Jqgrid is all ready?

I need the jqgrid load data when it is ready.So I have a function named LoadData() and bind click event for a button and write $("#btn").click() It's not used when ready event down.

And when I click that button it's used. I try make a timer of click event. It's used too. So I think When I use loadData function, the jqgrid not ready. How could I know Jqgrid is all ready?

function LoadData() {
    var PSCode = $("#sel_pollutant").val();
    var RegionCode = $("#RegionCode").val();
    $("#table_list_query").jqGrid('setGridParam', {
          url: "TransferEfficiencvData.ashx",
          datatype: 'json',
          postData: { "Action": "TransferEfficiencv", "RegionCode": RegionCode, "PSCode": PSCode }, 
          page: 1
    }).trigger("reloadGrid");
}

$(function(){
   var option = {
            //jqgrid config
        }
   $("#table_list_query").jqGrid(option);

   $("#btn").click(function () {
        LoadData();
   });
})

Upvotes: 1

Views: 1783

Answers (1)

Vinoth Krishnan
Vinoth Krishnan

Reputation: 2949

There are two events available in jQgrid to check whether the jQgrid is ready. They are,

  • gridComplete

This fires after all the data is loaded into the grid and all other processes are complete. Also the event fires independent from the datatype parameter and after sorting paging and etc.

gridComplete: function(){ 
    alert("grid completed");
}
  • loadComplete

This event is executed immediately after every server request. data Data from the response depending on datatype grid parameter

loadComplete: function(data)
{
    if(data != null){
        alert("load completed");
    }
},

Upvotes: 1

Related Questions