Wednesday, July 17, 2013

How to fix Master Table always NULL in get_masterTableView() method in Telerik Grid

I encounter a very weird issue today when i implemented a new feature with Telerik grid in my app

since i only manipulate the telerik grid from the client side.  the following is the snippet of my javascript code.

  var gridMasterTable = $find("<%=leadGrid.ClientID%>").get_masterTableView();
            gridMasterTable.set_dataSource(new Array());
            gridMasterTable.dataBind();

I try to bind the grid with empty array to show the grid. unfortunately the application always stop and show the warming message to indicate the master table is null.. it means that the table does not exist in the grid.

after I google the web for the solution, this post really help me identify the cause of the issue

http://www.telerik.com/community/forums/aspnet-ajax/grid/find-quot-lt-gridresults-clientid-gt-quot-get-mastertableview-is-coming-back-null.aspx

the trick to solve this issue is that when you bind your grid in the client side. you must have the onCommand property set in the ClientSettings section



 <ClientSettings>
         <ClientEvents OnGridCreated="leadGrid_Created" OnCommand="Customer_Command"/>
 </ClientSettings>

 

1 comment: