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

Calling NeedDatasource and DetailTableDataBind on button click

4 Answers 352 Views
Grid
This is a migrated thread and some comments may be shown as answers.
parimal
Top achievements
Rank 1
parimal asked on 03 Dec 2008, 08:26 AM
Hi,

I am in process of coding a three level hierarchy grid with client side hierarchy mode.I need to get data from DB on button click for some filter criteria and bind results to grid.

I wish to call the NeedDataSource and DetailsTableDataBind [this is called after needdatasource event is fired] event on button click to avoid error in JS method when hierarchy mode is CLIENT which says index out of bound.

 

 

 

function

 

ExpandFirstDetailTableFirstItem()

 

{

$find(

"<%= RadGrid1.Items[0].ChildItem.NestedTableViews[0].ClientID %>").expandItem(0);

 

}

 

 

function CollapseFirstDetailTableFirstItem()

 

{

$find(

"<%= RadGrid1.Items[0].ChildItem.NestedTableViews[0].ClientID %>").collapseItem(0);

 

}

 

 

 



I am looking following example on button click and and not on page load so tha NeedDatasource event is called after button click event is fired.

regards,

Parimal

 

 

 

 

 

 

 

4 Answers, 1 is accepted

Sort by
0
parimal
Top achievements
Rank 1
answered on 03 Dec 2008, 04:17 PM
Hi,

Please need help on urgent basis?

regards,

Parimal
0
Sebastian
Telerik team
answered on 05 Dec 2008, 01:03 PM
Hello Parimal,

In order to refresh the grid state and filter the data in it when pressing an external button, merely invoke the Rebind() method of the control. This will automatically raise the NeedDataSource/DetailTableDataBind events of the control to populate the master/detail tables content.

Kind regards,
Sebastian
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
parimal
Top achievements
Rank 1
answered on 05 Dec 2008, 09:38 PM
Hi,

The NeedDatasourceMethod gets called before Page load event and button click event [where i am making DB call with parameters], there is no data and then i get error in below these two methods:

ExpandFirstDetailTableFirstItem()
CollapseFirstDetailTableFirstItem()

stating index out of bound.

All you sample get data on Page load and so your samples dont have these issues.

My flow is:
1. Created Grid in Design time
2. Create detailstable and their parent relations in Page_Init event.
3. Calling Detailtablebind event for filter criteria.
4. Calling DB on button click event.

So on page load there is no data from DB and so getting errors in above mentioned methods. These two methods are must for CLientSide Hierarchy.

Can you send me  sample of your client side hierarchy demo on button click where it calls the DB and uses NeedDatasource method to call the DetailTableDatabind event to make filters on Dataview to bind to respective details tables?

http://demos.telerik.com/aspnet-ajax/Grid/Examples/Hierarchy/HierarchyLoadModeClient/DefaultCS.aspx

regards,

Parimal

0
Sebastian
Telerik team
answered on 08 Dec 2008, 04:34 PM

Hi Parimal,

The demo you requested is attached to this forum post (using the latest version 2008.3.1125 of RadControls for ASP.NET AJAX). Note that if you would like to create the grid hierarchy structure programmatically, you will need to instantiate your entire grid instance dynamically on PageInit as shown in these resources:

Online demo
Help topic

In case you want to keep the expanded state of the grid items when rebinding the grid on external button click, you will need to choose ServerOnDemand or ServerBind hierarchy load mode and utilize the approach presented here.

Best regards,
Sebastian,
the Telerik team

Tags
Grid
Asked by
parimal
Top achievements
Rank 1
Answers by
parimal
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or