This is a migrated thread and some comments may be shown as answers.

Get Grid Client functions from MasterPage

1 Answer 16 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Farhan
Top achievements
Rank 1
Farhan asked on 23 Sep 2011, 03:58 PM

Posted 1 minute ago (permalink)

Hi,
   I have been stuck on this problem for a couple of days and even with trying everything havnt been able to resolve this. I am using a Masterpage and content pages with RadGrid. I have read its better to put a RadAjaxManager on the main page and use RadAjaxmanagerproxy on each page. I have some common functions like the Show/Hide filters functionality as shown in the demos. Instead of having these and other Grid client side events I want to put  these common client side event in the Masterpage or preferably in an external js file but when i take them out and put them in the Masterpage it just does not let me access the Grid client side events like .get_MasterTableView() . Can someone from Telerik please show with an example how to access the grid and the grids clientside events in the Masterpage? Also can I call the functions  (showFilterItem() /hideFilterItem()) like showFilterItem(gridID)  and pass the GridClient ID to the masterpage somehow? I have these filter options on every page and dont want to repeat these and other client side events on every page or hard code the GridID (GridProducts, GridOrders etc) in the function like i am doing below, can someone show me by code example please how to pass in the Grid ID on every page to the master page to access the grid from there?

Note*: I did var grid = $('[id$=GridProducts]')[0];   in the Masterpage javscript since Masterpages changes the ID of the grid and it becomes something like ct100_Masterpagecontent_productGrid.

Please give an example in code on how to do this since im sure having common client side functionality is a common request and would hopefully others as well. Thanks in advance!


ON MASTER PAGE JAVASCRIPT:  
    
 <script type="text/javascript"
    
        function showFilterItem(grid) { 
                    
                //This finds the grid object but I cannot access  get_masterTableView() functions  
                var grid = $('[id$=GridProducts]')[0]; 
                    
              //Throws error Object reference not found??? 
                grid.get_masterTableView().showFilterItem(); 
            
    
            function hideFilterItem(grid) { 
                                           //Throws error cant find get_masterTableView() ??
                       grid.get_masterTableView().hideFilterItem();   
            
    
    </script
    
    
    
CONTENT PAGE HTML  
    
 <div style="text-align:center"
          <br /> 
            
             Show Filters:<input id="rad1" type="radio" name="showHideGroup" checked="checked" onclick="showFilterItem()" /><label for="rad1">Yes</label
                          <input id="rad2" type="radio" name="showHideGroup"  onclick="hideFilterItem()" /><label for="rad2">No</label
    
         </div>

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 23 Sep 2011, 06:18 PM
Hello,

please check below link.
http://www.telerik.com/community/forums/aspnet-ajax/grid/grid-clientside-functions-from-masterpage.aspx


Thanks,
Jayesh Goyani
Tags
Ajax
Asked by
Farhan
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or