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

[Solved] Expand rebinds mastertable

3 Answers 135 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeroen Eikmans
Top achievements
Rank 1
Jeroen Eikmans asked on 11 Feb 2010, 08:25 AM
Hello,

We have a Radgrid set up as followed
<telerik:RadGrid ID="RadGrid" runat="server" AutoGenerateColumns="False"   
  GridLines="None" AllowPaging="true" AllowCustomPaging="true" PageSize="100" AllowMultiRowSelection="true" 
  onitemcommand="RadGrid_ItemCommand" OnItemDataBound="RadGrid_ItemDataBound" 
  OnNeedDataSource="RadGrid_NeedDataSource" OnPreRender="RadGrid_PreRender" > 
  <ExportSettings> 
    <Pdf PageWidth="8.5in" PageHeight="11in" PageTopMargin="" PageBottomMargin="" PageLeftMargin="" PageRightMargin="" PageHeaderMargin="" PageFooterMargin=""></Pdf> 
  </ExportSettings> 
  <ClientSettings EnablePostBackOnRowClick="true" > 
    <Selecting AllowRowSelect="True" /> 
    <ClientEvents OnRowClick="RowClick" OnRowContextMenu="RowContextMenu" OnRowCreated="RowCreated" /> 
  </ClientSettings>

  <

 

MasterTableView Name="Customer" currentresetpageindexaction="SetPageIndexToFirst" DataKeyNames="CustomerNO" >

 

 
This radgrid has a detailtable that is set up as followed
<telerik:GridTableView runat="server" Name="Orders" AutoGenerateColumns="false" AllowSorting="false" 
   Width="100%" PageSize="20" AllowPaging="False" DataSourceID="UitvoeringenObjectDataSource" currentresetpageindexaction="SetPageIndexToFirst"   
   DataKeyNames="eKeyUITVRNG" > 
  <ParentTableRelation> 
    <telerik:GridRelationFields DetailKeyField="CustomerNO" MasterKeyField="CustomerNO" /> 
  </ParentTableRelation> 
 

When a user expands a row in the mastertable, the OnNeedDataSource event of the radgrid is also executed.
After that the rebind of the detailtable is triggered.

Why is the rebind of the mastertable taking place?
In my opinion only the detailtable should be bound at time of expanding and not the mastertable. Or is RadGrid triggering this because of some of the properties/events i set?

By the way, we're using version 2009.3.1208.35

Thanks in advance!

Kind regards,
Roel

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 11 Feb 2010, 10:11 AM
Hello Roel,

The  ExpandCollapse command makes an implicit call to the Rebind() method of RadGrid in order to refresh the control's content and fetch the latest information from the grid source.

You can find a list of other commands that fire the grid Rebind from the link below:
Commands that invoke Rebind() implicitly

Thanks,
Princy.
0
Jeroen Eikmans
Top achievements
Rank 1
answered on 11 Feb 2010, 01:16 PM
Hi Princy,

Thanks for your help.
That's a good list to remember...answered some questions i had about the radgrid.

Kind regards,
Roel
0
Jeroen Eikmans
Top achievements
Rank 1
answered on 18 Feb 2010, 09:36 AM
Hello,

I've been thinking a bit more about the fact that an explicit rebind is done for the mastertable when i expand an item.

The thing is that the rebind of the mastertable takes some time (about 7 seconds) because of the size of the DB and the SQL it needs to execute.
But when a user expands an item, the detailtable is very small (2 - 3 records) and that SQL takes less than 1 second to run.
For our users it seems that retrieving those 2 - 3 records takes an very long time, since the mastertable is rebound as well.

I've tested the radgrid when it's not doing the mastertable rebind by using a simple 'hack', setting a boolean in the OnItemCommand when CommandName = RadGrid.ExpandCollapseCommandName and in the OnNeedDataSource event check this variable and only do the bind when the bollean is false.
As far as i can tell everything is still working perfectly.

Is there a buildin way to turn this behaviour off? Or is the rebind absolutly necessary for a hierarchial radgrid to work?
Any ideas / opinions about this approach would be very appreciated!

Tags
Grid
Asked by
Jeroen Eikmans
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jeroen Eikmans
Top achievements
Rank 1
Share this question
or