hello,
where I can find a saple code for Grid.
I set Grid as
Browser="Xml"
ViewType="Hierarchical"
LoadOnDemand="Xml"
And added following code
protected void myDataGrid_InitializeDataSource(object sender, Infragistics.WebUI.UltraWebGrid.UltraGridEventArgs e) { this.myDataGrid.DataSource = GetGridData(); }
protected void myDataGrid_InitializeLayout(object sender, Infragistics.WebUI.UltraWebGrid.LayoutEventArgs e)
{
e.Layout.Bands[0].DataKeyField = "User_UID"; e.Layout.Bands[1].DataKeyField = "info_UID";
}
In GetGridData() function I fetch data from two tables of SQL database , fill dataset and define relations for this dataset.
This code works well but While debugging I found that when I click '+' sign on grid to view child rows, InitializeDataSource event fired again and it fetch data again from database.
I am confused whether it is correct behavior or not.Because for every '+' click it is loading data from SQL server .
Can any one guide me how to initialize data source for Hierarchical and LoadOnDemand="Xml" grid.
Or where I can find good example related to this?
Thanks
Shital
I think this is correct behavior. InitializeDatasource would be triggered in each server trip.
If you want to avoid SQL Database call then you need to store that data into Session variable.
It means Use GetGridData() to fetch data and store that value in Session. Then use Session data to bind with grid in subsequent server trips.
Then while Paging also it is fething records from server on every Page click, is it correct ?
If yes , then Grid is accessing all record from server on evey call, if mt table contains 5000 records then on every server trip it is accessing 50000 records ?
Please explain.
Yes, It would fetch all the records each time.
The base concept is: InitializeDataSource will be triggered each time on each server trip. This happens on any server events like button click, page index change, grid sort, grid filter. It also includes other AJAX calls on the page.
So in your case when InitializeDataSource is triggered it will fetch data from database.
Because of this reason I suggested to keep data into Session variable.
Thanks for information.
Where do I find good example for this ?
hello HBA,
Thank you very much for your support.
I ll look for these links and let u know abot this.
Check following samples
(1) Similar to your current approach: http://samples.infragistics.com/2008.2/WebFeatureBrowser/contents.aspx?showCode=True&t=WebGrid/LoadOnDemand/LoadOnDemand.aspx~srcview.aspx?path=../webfeaturebrowservb/WebGrid/LoadOnDemand/LoadOnDemand.src~srcview.aspx?path=WebGrid/LoadOnDemand/LoadOnDemand.src
(2) Using Session (here load on demand is not used but still data stored in session): http://samples.infragistics.com/2008.2/WebFeatureBrowser/contents.aspx?showCode=True&t=WebGrid/DatabaseUpdating/DatabaseUpdating.aspx~srcview.aspx?path=../webfeaturebrowservb/WebGrid/DatabaseUpdating/DatabaseUpdating.src~srcview.aspx?path=WebGrid/DatabaseUpdating/DatabaseUpdating.src
I am still searching exact sample as you need and post it when I get. You can also search it in sample browser here:
http://samples.infragistics.com/2008.2/webfeaturebrowser/default.htm