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

[Solved] cannot find appropriate client-side event

5 Answers 139 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tim R
Top achievements
Rank 1
Tim R asked on 10 Apr 2009, 04:27 PM
Most of my visible real-estate on the form contains textboxes for gathering search arguments, which are used to search a database, and the grid displays the results of the search. Only the top few rows of the grid are visible above the bottom of the window, and I'd like to be able to use the javascript NavigateTo() function to reposition the screen after the database results are returned and the grid is populated. 

function GridHasData {
NavigateTo('RESULTS');
}
<a id='RESULTS'></a>
<div id='telerikgridcontainer'>
  // grid here
</div>

But there doesn't seem to be a client-side event associated with "the grid has been populated with data".  Is there a way to invoke my function from the server side after I've assigned the datasource?

Thanks

5 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 13 Apr 2009, 03:27 PM
Hi Tim,

Please try handling the OnGridCreated client-side event of RadGrid for your purpose.
Find more information about this event here.

I hope this helps.

Greetings,
Iana
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Tim R
Top achievements
Rank 1
answered on 13 Apr 2009, 06:00 PM
Is there a way to determine in the OnGridCreated client-side eventhandler, whether the grid has been populated with data? My client-side code needs to execute only if the grid has been populated with data, and the onGridCreated event fires even if the grid has no data.

0
Iana Tsolova
Telerik team
answered on 16 Apr 2009, 07:56 AM
Hi Tim,

In order to determine if the grid has data rows or has no records displayed, you can try the below code:

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">  
<script type="text/javascript">  
function GridCreated(sender, eventArgs)  
{  
    if(sender.get_masterTableView().get_dataItems().length > 0)  
    {  
        //execute custom code here  
    }  
}  
</script>  
</telerik:RadCodeBlock> 
<telerik:RadGrid ID="RadGrid1" runat="server">  
    <ClientSettings> 
        <ClientEvents OnGridCreated="GridCreated" /> 
    </ClientSettings> 
</telerik:RadGrid> 

I hope this would work for you.

Greetings,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Tim R
Top achievements
Rank 1
answered on 16 Apr 2009, 04:01 PM
When I take the approach suggested in the GridCreated client-side eventhandler, namely

if(sender.get_masterTableView().get_dataItems().length > 0)  
.
.
.

there is this error:

Microsoft JScript runtime error: 'this._tableView._owner._clientKeyValues' is null or not an object

at this location in Telerik code:

if(this._tableView&&this._tableView._owner._clientKeyValues&&this._tableView._owner._clientKeyValues[this._itemIndexHierarchical]){
this._dataKeyValues=this._tableView._owner._clientKeyValues[this._itemIndexHierarchical];
}
}
this._domEvent=_369;

Is this error the result of something I'm failing to do? I'm assigning a System.Data.Datatable as the grid's Datasource, and here is how the MasterTableView is declared in HTML:

 

<

 

telerik:RadGrid ID="RadGrid1" runat="server" ValidationSettings-EnableValidation="true" AutoGenerateColumns="False" GroupingEnabled="False" PageSize="22" GridLines="None">

 

 

 

 

 

<mastertableview ClientDataKeynames="id" datakeynames="id" cssclass="mastertable_default" showheader="False" gridLines="None">

 

 

 


Thanks for the continued help.

0
Iana Tsolova
Telerik team
answered on 17 Apr 2009, 01:42 PM
Hi Tim,

Your grid and MasterTableView declarations look fine to me, I cannot find any reason for the preceding error there.
I suggest that you check out the attached sample which implements the previously provided solution and see how it works and what differs in your case.

Let me know how it goes.

Sincerely yours,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Tim R
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Tim R
Top achievements
Rank 1
Share this question
or