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

[Solved] Client Event "OnGridCreated" not firing

3 Answers 541 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 15 Jul 2009, 07:21 PM

I'm trying to emulate the "Client-side" data binding demo page, but when i try to get the mastertableview in javascript, i get an error about it being null.  After some searching here in the forums, i saw that i couldn't get the mastertableview until after the gridCreated client event had fired.  I tried moving my code here, but the function isn't being called.  The code for the grid is attached below.

Thanks,
Matt

                <tel:RadGrid ID="kgSearch" runat="server" Skin="Vista">  
                   <MasterTableView TableLayout="Fixed">  
                        <Columns> 
                            <tel:GridBoundColumn DataField="USER_ID" HeaderText="User ID"></tel:GridBoundColumn> 
                            <tel:GridBoundColumn DataField="LAST_NAME" HeaderText="Last Name"></tel:GridBoundColumn> 
                            <tel:GridBoundColumn DataField="FIRST_NAME" HeaderText="First Name"></tel:GridBoundColumn> 
                            <tel:GridBoundColumn DataField="USERNAME" HeaderText="Username"></tel:GridBoundColumn> 
                        </Columns>                          
                   </MasterTableView> 
                   <ClientSettings> 
                    <ClientEvents OnGridCreated="gridCreated" /> 
                   </ClientSettings> 
                </tel:RadGrid> 

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 Jul 2009, 06:45 AM
Hi Matt,

I haven’t found setting DataSourceID for grid or even attached OnNeedDataSource event. How do you bind the RadGrid?


-Shinu.
0
Matt
Top achievements
Rank 1
answered on 16 Jul 2009, 12:34 PM
On client page load i call a web service to bind the grid:

                function pageLoad()  
                {  
                    var elements =  
                    {  
                        kgSearch: '<%= kgSearch.ClientID %>',  
                        txtSearch: '<%= txtSearch.ClientID %>',  
                        btnSearch: '<%= btnSearch.ClientID %>',  
                        id: '<%= ClientID %>' 
                    }  
                    <%= ClientID %> = $create(widget_test.UserSearch, elements, nullnullnull);  
                      
                    $find('<%= ClientID %>').search();  
                } 

The 'grid' variable below can be found, but the masterTableView is null.

    search: function() {  
        svcUsers.Search(this._txtSearch.value, Function.createDelegate(thisthis.onSuccess), Function.createDelegate(thisthis.onFailure));  
    },  
 
    onSuccess: function(result) {  
        var grid = $find(this._kgSearch);  
        var tblView = grid.get_masterTableView();  
        tblView.set_dataSource(result);  
        tblView.dataBind();  
    },  
 
    onError: function(error) {  
        alert(error.get_message());  
    } 
0
Matt
Top achievements
Rank 1
answered on 16 Jul 2009, 01:47 PM
I was able to figure it out.  I think this is kind of a hack, but in order to create the grid, i needed to attach an client event hander to the "OnCommand" client function.  For some reason this made the grid render on the page so i was able to access the mastertableview.

                function kgSearch_Command(sender, args)  
                {  
                    args.set_cancel(true);  
                }   

 

                <tel:RadGrid ID="kgSearch" runat="server" Skin="Vista">  
                   <MasterTableView TableLayout="Fixed">  
                        <Columns> 
                            <tel:GridBoundColumn DataField="ID" HeaderText="User ID"></tel:GridBoundColumn> 
                            <tel:GridBoundColumn DataField="LastName" HeaderText="Last Name"></tel:GridBoundColumn> 
                            <tel:GridBoundColumn DataField="FirstName" HeaderText="First Name"></tel:GridBoundColumn> 
                            <tel:GridBoundColumn DataField="Username" HeaderText="Username"></tel:GridBoundColumn> 
                        </Columns>                          
                   </MasterTableView> 
                   <ClientSettings> 
                    <ClientEvents OnCommand="kgSearch_Command"/>  
                   </ClientSettings> 
                </tel:RadGrid>     
Tags
Grid
Asked by
Matt
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Matt
Top achievements
Rank 1
Share this question
or