Hello,
I have a hierarchical Radgrid in which each level in the hierarchy uses different data table. I have 4 levels in hierarchy and the last level is a hyperlink column.
On ItemCommand even (i.e on clicking + sign in the grid) is captured. In this function i.e RadGrid2_ItemCommand(object sender, GridCommandEventArgs e)
i want to remove all the DetailTableviews and add a new one.
How can this be accomplished. I tried
e.Item.OwnerTableView.DetailTables.Remove(e.Item.OwnerTableView.DetailTables[0]);
but this doesn't work and also I am not able to add any new tableview to this current tableview in context.
Please let me know how can this be accomplished and if all these levels can be created dynamically on ItemCommand
Also, can I attach a + sign to any tableview that doesn't have any child/ detailtable view ?
Thanks
I have a hierarchical Radgrid in which each level in the hierarchy uses different data table. I have 4 levels in hierarchy and the last level is a hyperlink column.
On ItemCommand even (i.e on clicking + sign in the grid) is captured. In this function i.e RadGrid2_ItemCommand(object sender, GridCommandEventArgs e)
i want to remove all the DetailTableviews and add a new one.
How can this be accomplished. I tried
e.Item.OwnerTableView.DetailTables.Remove(e.Item.OwnerTableView.DetailTables[0]);
but this doesn't work and also I am not able to add any new tableview to this current tableview in context.
Please let me know how can this be accomplished and if all these levels can be created dynamically on ItemCommand
Also, can I attach a + sign to any tableview that doesn't have any child/ detailtable view ?
Thanks
24 Answers, 1 is accepted
0

Hary
Top achievements
Rank 1
answered on 10 Jul 2008, 02:37 AM
I gave it some more time and efforts and I could detailtableviews from currenttableview.
Now the problem is as follows:
In RadGrid2_ItemCommand method, I want to delete all the detail table views for a particular table view and then add a different table view for it. I did the following to accomplish this but in vein
protected void RadGrid2_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.Item.OwnerTableView.Name == "tableViewINS")
{
e.Item.OwnerTableView.DetailTables.Remove(e.Item.OwnerTableView.DetailTables[0]);
GridTableView tableViewPRJ = new GridTableView(RadGrid2);
tableViewPRJ.DataSource = dtUserData.DefaultView;
tableViewPRJ.Name = "tableViewPRJ";
tableViewPRJ.Width = Unit.Percentage(100);
e.Item.OwnerTableView.DetailTables.Add(tableViewPRJ);
GridHyperLinkColumn hyperlinkColumn = new GridHyperLinkColumn();
hyperlinkColumn.HeaderText = "Data Availability Status";
hyperlinkColumn.Text = "NOT Available";
hyperlinkColumn.NavigateUrl = "default.aspx";
hyperlinkColumn.Target = "_blank";
tableViewPRJ.Columns.Add(hyperlinkColumn);
e.Item.OwnerTableView.HierarchyDefaultExpanded = true;
e.Item.OwnerTableView.Rebind();
}
}
Now what's happening is that if I don't set
e.Item.OwnerTableView.HierarchyDefaultExpanded = true;
then the + sign at current level doesn't do anything.
And if I do set this value, I see "NOT Available" hyperlink multiple times.
Can anyone tell me where am I messing up my code.
Thanks
Now the problem is as follows:
In RadGrid2_ItemCommand method, I want to delete all the detail table views for a particular table view and then add a different table view for it. I did the following to accomplish this but in vein
protected void RadGrid2_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.Item.OwnerTableView.Name == "tableViewINS")
{
e.Item.OwnerTableView.DetailTables.Remove(e.Item.OwnerTableView.DetailTables[0]);
GridTableView tableViewPRJ = new GridTableView(RadGrid2);
tableViewPRJ.DataSource = dtUserData.DefaultView;
tableViewPRJ.Name = "tableViewPRJ";
tableViewPRJ.Width = Unit.Percentage(100);
e.Item.OwnerTableView.DetailTables.Add(tableViewPRJ);
GridHyperLinkColumn hyperlinkColumn = new GridHyperLinkColumn();
hyperlinkColumn.HeaderText = "Data Availability Status";
hyperlinkColumn.Text = "NOT Available";
hyperlinkColumn.NavigateUrl = "default.aspx";
hyperlinkColumn.Target = "_blank";
tableViewPRJ.Columns.Add(hyperlinkColumn);
e.Item.OwnerTableView.HierarchyDefaultExpanded = true;
e.Item.OwnerTableView.Rebind();
}
}
Now what's happening is that if I don't set
e.Item.OwnerTableView.HierarchyDefaultExpanded = true;
then the + sign at current level doesn't do anything.
And if I do set this value, I see "NOT Available" hyperlink multiple times.
Can anyone tell me where am I messing up my code.
Thanks
0

Hary
Top achievements
Rank 1
answered on 10 Jul 2008, 03:10 PM
Hello Telerik team,
Can anyone please look into my problem. I've been trying hard to get this resolved but in vein and this is proving to be a big show stopper in my task.
I request you guys to please have a look and let me know what could be done to solve this issue.
Thanks in advance.
Hary
Can anyone please look into my problem. I've been trying hard to get this resolved but in vein and this is proving to be a big show stopper in my task.
I request you guys to please have a look and let me know what could be done to solve this issue.
Thanks in advance.
Hary
0
Hello Hary,
Generally add and remove of detail tables on the fly can cause lots of troubles because of the VIewState however if you send us small example project via support ticket along with detailed info about desired result we will do our best to help you.
Sincerely yours,
Vlad
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Generally add and remove of detail tables on the fly can cause lots of troubles because of the VIewState however if you send us small example project via support ticket along with detailed info about desired result we will do our best to help you.
Sincerely yours,
Vlad
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

Hary
Top achievements
Rank 1
answered on 10 Jul 2008, 04:26 PM
Hello,
What I want to accomplish is as follows:
1. A hierarchical grid and the last level in each hieararchy should be a hyperlink column. I could have used Self-referencing grids but I read in one of the posts by your team member that this is not achievable in self-referencing grids.
My code is as follows (just the main parts to make to look clear and readable):
****************************************88
RadGrid RadGrid2 = new RadGrid(); // RadGrid object defined Globally so that it can be used in various RadGrid events (used for dynamically removing rows)
protected void Page_Load(object sender, EventArgs e)
{
GenerateGrid(dtUserData); //dtUserData is a global data table
}
private void GenerateGrid(DataTable dtUserData)
{
// User dtUserData and select only those rows that I need to use for the master table view of Radgrid
// I call this Data Table myTable
RadGrid2.DataSource = myTable;
RadGrid2.ItemCommand += new GridCommandEventHandler(RadGrid2_ItemCommand);
//The following key values would be used to set relations between the master table and its DetailTableView
RadGrid2.MasterTableView.DataKeyNames = new string[] { "DT_NAME", "DS_NAME" };
// Then I have a boundColumn for the master table
GridBoundColumn boundColumn;
boundColumn = new GridBoundColumn();
boundColumn.DataField = "DS_NAME";
//boundColumn.HeaderText = "Data Store Name";
RadGrid2.MasterTableView.Columns.Add(boundColumn);
// After that I have a Group by expression for the master table
// Grouped on DT_NAME (not pasting the code for that)
// Then using dtUserData data table parameter for this function, I make the data table for the detail table view for the master table view.
// I call it myTable1
GridTableView tableViewDS = new GridTableView(RadGrid2);
tableViewDS.Name = "tableViewDS";
tableViewDS.DataSource = myTable1;
tableViewDS.DataKeyNames = new string[] { "DT_NAME", "DS_NAME", "INS_NAME" };
// Then I set relations for tableViewDS which is the DeatilTableView for my master table view (Relations are set on DT_NAME and DS_NAME which are the key values in the MasterTableView.
RadGrid2.MasterTableView.DetailTables.Add(tableViewDS);
// Similarly I have a deatil table view for tableViewDS called tableViewINS and furthermore, tableViewINS has another detailed table view called tableViewPRJ
}
***************************************
*************************************
Now the problem:
1. tableViewPrj should have a hyperlink colulmn based on the values of a KeyValue named "DATA" in its parent table tableViewINS
I try to access the DataKeyValues of tableViewINS but in vein. It says index out of range. I do a data bind of every table view as soon as i create it so that when I try to access its keyValues, I should have something handy. Doesn't work.
2. So another problem here is how and when and what to DataBind after a table view is created so that its key values could be accessed right after it was created for its deatil table views. Something like, if for Radgrid2 I assign its datasource and then create a detailtable or may call it its child table which is going to use the key values from its parent then should mastertable view's databind property already be called ? Kind of confused here.
3. The hyperlink column that I talked about earlier for the final table view depends on what values DATA key has in its parent i.e tableviewINS.
So yes, this is what I am trying to accomplish.
Can you suggest something here. I'll be highly obliged if I get a quick solution as this is creeping up a lot of delay in my task.
Thanks and regards,
Hary
What I want to accomplish is as follows:
1. A hierarchical grid and the last level in each hieararchy should be a hyperlink column. I could have used Self-referencing grids but I read in one of the posts by your team member that this is not achievable in self-referencing grids.
My code is as follows (just the main parts to make to look clear and readable):
****************************************88
RadGrid RadGrid2 = new RadGrid(); // RadGrid object defined Globally so that it can be used in various RadGrid events (used for dynamically removing rows)
protected void Page_Load(object sender, EventArgs e)
{
GenerateGrid(dtUserData); //dtUserData is a global data table
}
private void GenerateGrid(DataTable dtUserData)
{
// User dtUserData and select only those rows that I need to use for the master table view of Radgrid
// I call this Data Table myTable
RadGrid2.DataSource = myTable;
RadGrid2.ItemCommand += new GridCommandEventHandler(RadGrid2_ItemCommand);
//The following key values would be used to set relations between the master table and its DetailTableView
RadGrid2.MasterTableView.DataKeyNames = new string[] { "DT_NAME", "DS_NAME" };
// Then I have a boundColumn for the master table
GridBoundColumn boundColumn;
boundColumn = new GridBoundColumn();
boundColumn.DataField = "DS_NAME";
//boundColumn.HeaderText = "Data Store Name";
RadGrid2.MasterTableView.Columns.Add(boundColumn);
// After that I have a Group by expression for the master table
// Grouped on DT_NAME (not pasting the code for that)
// Then using dtUserData data table parameter for this function, I make the data table for the detail table view for the master table view.
// I call it myTable1
GridTableView tableViewDS = new GridTableView(RadGrid2);
tableViewDS.Name = "tableViewDS";
tableViewDS.DataSource = myTable1;
tableViewDS.DataKeyNames = new string[] { "DT_NAME", "DS_NAME", "INS_NAME" };
// Then I set relations for tableViewDS which is the DeatilTableView for my master table view (Relations are set on DT_NAME and DS_NAME which are the key values in the MasterTableView.
RadGrid2.MasterTableView.DetailTables.Add(tableViewDS);
// Similarly I have a deatil table view for tableViewDS called tableViewINS and furthermore, tableViewINS has another detailed table view called tableViewPRJ
}
***************************************
*************************************
Now the problem:
1. tableViewPrj should have a hyperlink colulmn based on the values of a KeyValue named "DATA" in its parent table tableViewINS
I try to access the DataKeyValues of tableViewINS but in vein. It says index out of range. I do a data bind of every table view as soon as i create it so that when I try to access its keyValues, I should have something handy. Doesn't work.
2. So another problem here is how and when and what to DataBind after a table view is created so that its key values could be accessed right after it was created for its deatil table views. Something like, if for Radgrid2 I assign its datasource and then create a detailtable or may call it its child table which is going to use the key values from its parent then should mastertable view's databind property already be called ? Kind of confused here.
3. The hyperlink column that I talked about earlier for the final table view depends on what values DATA key has in its parent i.e tableviewINS.
So yes, this is what I am trying to accomplish.
Can you suggest something here. I'll be highly obliged if I get a quick solution as this is creeping up a lot of delay in my task.
Thanks and regards,
Hary
0

Hary
Top achievements
Rank 1
answered on 10 Jul 2008, 04:26 PM
Hello,
What I want to accomplish is as follows:
1. A hierarchical grid and the last level in each hieararchy should be a hyperlink column. I could have used Self-referencing grids but I read in one of the posts by your team member that this is not achievable in self-referencing grids.
My code is as follows (just the main parts to make to look clear and readable):
****************************************88
RadGrid RadGrid2 = new RadGrid(); // RadGrid object defined Globally so that it can be used in various RadGrid events (used for dynamically removing rows)
protected void Page_Load(object sender, EventArgs e)
{
GenerateGrid(dtUserData); //dtUserData is a global data table
}
private void GenerateGrid(DataTable dtUserData)
{
// User dtUserData and select only those rows that I need to use for the master table view of Radgrid
// I call this Data Table myTable
RadGrid2.DataSource = myTable;
RadGrid2.ItemCommand += new GridCommandEventHandler(RadGrid2_ItemCommand);
//The following key values would be used to set relations between the master table and its DetailTableView
RadGrid2.MasterTableView.DataKeyNames = new string[] { "DT_NAME", "DS_NAME" };
// Then I have a boundColumn for the master table
GridBoundColumn boundColumn;
boundColumn = new GridBoundColumn();
boundColumn.DataField = "DS_NAME";
//boundColumn.HeaderText = "Data Store Name";
RadGrid2.MasterTableView.Columns.Add(boundColumn);
// After that I have a Group by expression for the master table
// Grouped on DT_NAME (not pasting the code for that)
// Then using dtUserData data table parameter for this function, I make the data table for the detail table view for the master table view.
// I call it myTable1
GridTableView tableViewDS = new GridTableView(RadGrid2);
tableViewDS.Name = "tableViewDS";
tableViewDS.DataSource = myTable1;
tableViewDS.DataKeyNames = new string[] { "DT_NAME", "DS_NAME", "INS_NAME" };
// Then I set relations for tableViewDS which is the DeatilTableView for my master table view (Relations are set on DT_NAME and DS_NAME which are the key values in the MasterTableView.
RadGrid2.MasterTableView.DetailTables.Add(tableViewDS);
// Similarly I have a deatil table view for tableViewDS called tableViewINS and furthermore, tableViewINS has another detailed table view called tableViewPRJ
}
***************************************
*************************************
Now the problem:
1. tableViewPrj should have a hyperlink colulmn based on the values of a KeyValue named "DATA" in its parent table tableViewINS
I try to access the DataKeyValues of tableViewINS but in vein. It says index out of range. I do a data bind of every table view as soon as i create it so that when I try to access its keyValues, I should have something handy. Doesn't work.
2. So another problem here is how and when and what to DataBind after a table view is created so that its key values could be accessed right after it was created for its deatil table views. Something like, if for Radgrid2 I assign its datasource and then create a detailtable or may call it its child table which is going to use the key values from its parent then should mastertable view's databind property already be called ? Kind of confused here.
3. The hyperlink column that I talked about earlier for the final table view depends on what values DATA key has in its parent i.e tableviewINS.
So yes, this is what I am trying to accomplish.
Can you suggest something here. I'll be highly obliged if I get a quick solution as this is creeping up a lot of delay in my task.
Thanks and regards,
Hary
What I want to accomplish is as follows:
1. A hierarchical grid and the last level in each hieararchy should be a hyperlink column. I could have used Self-referencing grids but I read in one of the posts by your team member that this is not achievable in self-referencing grids.
My code is as follows (just the main parts to make to look clear and readable):
****************************************88
RadGrid RadGrid2 = new RadGrid(); // RadGrid object defined Globally so that it can be used in various RadGrid events (used for dynamically removing rows)
protected void Page_Load(object sender, EventArgs e)
{
GenerateGrid(dtUserData); //dtUserData is a global data table
}
private void GenerateGrid(DataTable dtUserData)
{
// User dtUserData and select only those rows that I need to use for the master table view of Radgrid
// I call this Data Table myTable
RadGrid2.DataSource = myTable;
RadGrid2.ItemCommand += new GridCommandEventHandler(RadGrid2_ItemCommand);
//The following key values would be used to set relations between the master table and its DetailTableView
RadGrid2.MasterTableView.DataKeyNames = new string[] { "DT_NAME", "DS_NAME" };
// Then I have a boundColumn for the master table
GridBoundColumn boundColumn;
boundColumn = new GridBoundColumn();
boundColumn.DataField = "DS_NAME";
//boundColumn.HeaderText = "Data Store Name";
RadGrid2.MasterTableView.Columns.Add(boundColumn);
// After that I have a Group by expression for the master table
// Grouped on DT_NAME (not pasting the code for that)
// Then using dtUserData data table parameter for this function, I make the data table for the detail table view for the master table view.
// I call it myTable1
GridTableView tableViewDS = new GridTableView(RadGrid2);
tableViewDS.Name = "tableViewDS";
tableViewDS.DataSource = myTable1;
tableViewDS.DataKeyNames = new string[] { "DT_NAME", "DS_NAME", "INS_NAME" };
// Then I set relations for tableViewDS which is the DeatilTableView for my master table view (Relations are set on DT_NAME and DS_NAME which are the key values in the MasterTableView.
RadGrid2.MasterTableView.DetailTables.Add(tableViewDS);
// Similarly I have a deatil table view for tableViewDS called tableViewINS and furthermore, tableViewINS has another detailed table view called tableViewPRJ
}
***************************************
*************************************
Now the problem:
1. tableViewPrj should have a hyperlink colulmn based on the values of a KeyValue named "DATA" in its parent table tableViewINS
I try to access the DataKeyValues of tableViewINS but in vein. It says index out of range. I do a data bind of every table view as soon as i create it so that when I try to access its keyValues, I should have something handy. Doesn't work.
2. So another problem here is how and when and what to DataBind after a table view is created so that its key values could be accessed right after it was created for its deatil table views. Something like, if for Radgrid2 I assign its datasource and then create a detailtable or may call it its child table which is going to use the key values from its parent then should mastertable view's databind property already be called ? Kind of confused here.
3. The hyperlink column that I talked about earlier for the final table view depends on what values DATA key has in its parent i.e tableviewINS.
So yes, this is what I am trying to accomplish.
Can you suggest something here. I'll be highly obliged if I get a quick solution as this is creeping up a lot of delay in my task.
Thanks and regards,
Hary
0

Hary
Top achievements
Rank 1
answered on 10 Jul 2008, 06:58 PM
To add more to what I already sent you guys, to make my code look cleaner and meaningful I am now making use of the following 2 events:
RadGrid2.NeedDataSource += new GridNeedDataSourceEventHandler(this.RadGrid2_NeedDataSource);
RadGrid2.DetailTableDataBind += new GridDetailTableDataBindEventHandler(this.RadGrid2_DetailTableDataBind);
Now these events are fired after GenerateGrid(DataTable dtUserData) is executed. That means, if I try to use the datakey values of DetailTableView at level 2 while creating level 3 then these values won't be available because databind even hasn't been fired yet.
Is there anything called forced bind or smth to accomplish my goal.
To-reiterate I want to create a hyperlink column at level 4 based on datakey values at level 3.
Thanks,
Hary
RadGrid2.NeedDataSource += new GridNeedDataSourceEventHandler(this.RadGrid2_NeedDataSource);
RadGrid2.DetailTableDataBind += new GridDetailTableDataBindEventHandler(this.RadGrid2_DetailTableDataBind);
Now these events are fired after GenerateGrid(DataTable dtUserData) is executed. That means, if I try to use the datakey values of DetailTableView at level 2 while creating level 3 then these values won't be available because databind even hasn't been fired yet.
Is there anything called forced bind or smth to accomplish my goal.
To-reiterate I want to create a hyperlink column at level 4 based on datakey values at level 3.
Thanks,
Hary
0

Hary
Top achievements
Rank 1
answered on 10 Jul 2008, 07:24 PM
Also,
After adding a detailtable view inside another detailtable view,
value of detailTableView2.Items.Count is zero
and ChildItem.NestedTableViews.Length for the tableView down in the hierarchy for which new detailTableView was added is Zero too.
Why this behavior ?
Thanks,
After adding a detailtable view inside another detailtable view,
value of detailTableView2.Items.Count is zero
and ChildItem.NestedTableViews.Length for the tableView down in the hierarchy for which new detailTableView was added is Zero too.
Why this behavior ?
Thanks,
0

Hary
Top achievements
Rank 1
answered on 10 Jul 2008, 11:03 PM
Also, I was unable to enter a support ticket for the same.
To re-iterate I am really stuck with this problem.
Please suggest something asap
Thanks,
Hary
To re-iterate I am really stuck with this problem.
Please suggest something asap
Thanks,
Hary
0

Hary
Top achievements
Rank 1
answered on 11 Jul 2008, 06:01 PM
I eventually figured out how to do it.
I bound my hierarchical grid (all tableviews) with appropriate datatables and keep column of the last tableview as a hyperlink.
Then in ItemDataBound event's function, I check for the value of hyperlink column and enable/disable it as per what value it has.
There's one problem that I am facing now.
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
{
GridDataItem item = (GridDataItem)e.Item;
if (//some condition)
{
item["DATA"].Text = "some value" ;
}
}
The thing is that I see this value for hyperlink column being set in ItemDataBound method.
However, when I click any + sign, the row for hyperlink column disappears. Actually I guess it gets hidden under some other layer because when I click on its + sign, i can see it again.
Any solution to this one ?
thanks
I bound my hierarchical grid (all tableviews) with appropriate datatables and keep column of the last tableview as a hyperlink.
Then in ItemDataBound event's function, I check for the value of hyperlink column and enable/disable it as per what value it has.
There's one problem that I am facing now.
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
{
GridDataItem item = (GridDataItem)e.Item;
if (//some condition)
{
item["DATA"].Text = "some value" ;
}
}
The thing is that I see this value for hyperlink column being set in ItemDataBound method.
However, when I click any + sign, the row for hyperlink column disappears. Actually I guess it gets hidden under some other layer because when I click on its + sign, i can see it again.
Any solution to this one ?
thanks
0
Hello Hary,
First of all you should add the column to collection then setting its properties when using Load event.
I would suggest you to read the topic Programmatic creation and also you may take a look at the following demos concerning RadGrid:
Daniel
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
First of all you should add the column to collection then setting its properties when using Load event.
GridHyperLinkColumn hyperlinkColumn = new GridHyperLinkColumn(); |
tableViewPRJ.Columns.Add(hyperlinkColumn); |
hyperlinkColumn.HeaderText = "Data Availability Status"; |
hyperlinkColumn.Text = "NOT Available"; |
hyperlinkColumn.NavigateUrl = "default.aspx"; |
hyperlinkColumn.Target = "_blank"; |
I would suggest you to read the topic Programmatic creation and also you may take a look at the following demos concerning RadGrid:
- Programmatic creation - On PageInit
- Programmatic creation - On PageLoad
- Programmatic creation - Creating hierarchy programmatically
Daniel
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

Jas
Top achievements
Rank 1
answered on 16 Jul 2008, 04:54 AM
Thanks for the pointers and advice Daniel. That did work
Now a very strange thing is happening and on reading various posts here, I realized that others faced the same problem too.
I have 4 levels of hierarchy and I create my Hierarchical RadGrid on page_load and I followed each and every thing that I had to for the page_load way of doing it
Now the thing is that if I use RadAjaxManager1 and don't postback and use view state to show various nodes of the grid, it doesn't do anything for level 3 and 4. i.e I would stop at level 2 and I won't see anything for levels 3 and 4.
To check what's going on wrong, on postBack, I call the same RadGrid creating function to do each and every thing all over again and when i click on + of node 2 then it says
Parent table relations set, but no correspoding data-key name found
However, I have my relations well in place but it is somehow not copying it to the next server submit i.e post back
So i added parent-child relations for the 3rd and 4th level in the detailTableDataBind function something like this
e.DetailTableView.ParentTableRelation[0].DetailKeyField = "DT_NAME";
e.DetailTableView.ParentTableRelation[0].MasterKeyField = "DT_NAME";
and it works fine.
However, if I don't call the Grid Generating function on postback and try to use the viewstate value of the grid using RadAjaxManager1, it does the same i.e. doesn't show up anything for the 3rd and the 4th level.
Can you please tell me whats going on here.
Please see a copy of my RidGenerating function (first 3 levels only, 3 doesn't show up in the grid)
protected void Page_Load(object sender, EventArgs e)
{
RadGrid2 = new RadGrid();
RadGrid2.ID = "RadGrid2";
this.PlaceHolder1.Controls.Add(RadGrid2);
if (!IsPostBack)
{
XmlNodeUserSelectedData = getData(userName, gadgetID, UWI);
dtUserData = objCommon.MakeDataTable_SelectedUser(XmlNodeUserSelectedData, "Data");
ViewState["DataTable_SelectedUserData"] = dtUserData;
ViewState["XmlNodeUserSelectedData"] = XmlNodeUserSelectedData.OuterXml.ToString(); //converted to string because xmlnode can't be passed in view state
GenerateGrid(dtUserData);
}
}
-----------------------------------------------------
--------------------------------------------------------
private void GenerateGrid(DataTable dtUserData)
{
//RadGrid2.MasterTableView.DataSource = GetDataTable(dtUserData, "DT");
RadGrid2.ID = "RadGrid2";
GridRelationFields relationFields;
RadGrid2.NeedDataSource += new GridNeedDataSourceEventHandler(this.RadGrid2_NeedDataSource);
RadGrid2.DetailTableDataBind += new GridDetailTableDataBindEventHandler(this.RadGrid2_DetailTableDataBind);
RadGrid2.ItemDataBound += new GridItemEventHandler(RadGrid2_ItemDataBound);
//RadGrid2.PreRender += new EventHandler(RadGrid2_PreRender);
RadGrid2.Skin = "Office2007";
RadGrid2.Width = Unit.Percentage(100);
RadGrid2.PageSize = 12;
RadGrid2.AllowPaging = true;
//RadGrid2.ClientSettings.Scrolling.AllowScroll = true;
//RadGrid2.ClientSettings.Scrolling.ScrollHeight = 10;
RadGrid2.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;
RadGrid2.AutoGenerateColumns = false;
RadGrid2.GroupingEnabled = true;
RadGrid2.EnableAJAX = true;
RadGrid2.ShowGroupPanel = true;
RadGrid2.MasterTableView.Name = "tableViewDT";
RadGrid2.MasterTableView.HierarchyLoadMode = GridChildLoadMode.ServerBind;
RadGrid2.MasterTableView.HierarchyDefaultExpanded = false;
RadGrid2.MasterTableView.PageSize = 12;
RadGrid2.MasterTableView.Width = Unit.Percentage(100);
//RadGrid2.MasterTableView.DataKeyNames = new string[] { "DT_NAME", "DS_NAME", "INS_NAME", "PRJ_NAME", "DATA" };
RadGrid2.MasterTableView.DataKeyNames = new string[] { "DT_NAME", "DS_NAME" };
GridBoundColumn boundColumn = new GridBoundColumn();
RadGrid2.MasterTableView.Columns.Add(boundColumn);
boundColumn.DataField = "DS_NAME";
///////////////////////////////////////////////////////////////////////////////////////
///////////////////DEFINE GROUPBY EXPRESSION FOR GRID MASTER TABLE VIEW/////////////////
///////////////////////////////////////////////////////////////////////////////////////
GridGroupByExpression expression = new GridGroupByExpression();
GridGroupByField gridGroupByField = new GridGroupByField();
// SelectFields values (appear in header)
gridGroupByField = new GridGroupByField();
gridGroupByField.FieldName = "DT_NAME";
gridGroupByField.HeaderText = "Data Type";
//gridGroupByField.FormatString = "<strong>{0}</strong>";
gridGroupByField.FormatString = "{0}";
expression.SelectFields.Add(gridGroupByField);
//GroupByFields values (group data)
gridGroupByField = new GridGroupByField();
gridGroupByField.FieldName = "DT_NAME";
expression.GroupByFields.Add(gridGroupByField);
RadGrid2.MasterTableView.GroupByExpressions.Add(expression);
/////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////DEFINE DETAIL TABLE VIEW (tableViewDS) FOR THE MASTER TABLE VIEW///////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
//Add first and then set the properties (to make viewstate persist on post_back)
GridTableView tableViewDS = new GridTableView(RadGrid2);
RadGrid2.MasterTableView.DetailTables.Add(tableViewDS);
tableViewDS.Name = "tableViewDS";
tableViewDS.ID = "tableViewDS";
//tableViewDS.DataSource = GetDataTable(dtUserData, "DS");
//tableViewDS.DataKeyNames = new string[] { "DT_NAME", "DS_NAME", "INS_NAME", "PRJ_NAME", "DATA" };
tableViewDS.DataKeyNames = new string[] { "DT_NAME", "DS_NAME", "INS_NAME"};
tableViewDS.Width = Unit.Percentage(100);
relationFields = new GridRelationFields();
tableViewDS.ParentTableRelation.Add(relationFields);
relationFields.MasterKeyField = "DT_NAME";
relationFields.DetailKeyField = "DT_NAME";
relationFields = new GridRelationFields();
tableViewDS.ParentTableRelation.Add(relationFields);
relationFields.MasterKeyField = "DS_NAME";
relationFields.DetailKeyField = "DS_NAME";
//RadGrid2.MasterTableView.DetailTables.Add(tableViewDS);
boundColumn = new GridBoundColumn();
tableViewDS.Columns.Add(boundColumn);
boundColumn.DataField = "INS_NAME";
/////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////DEFINE DETAIL TABLE VIEW (tableViewINS) FOR THE tableViewDS///////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
//Add first and then set the properties (to make viewstate persist on post_back)
GridTableView tableViewINS = new GridTableView(RadGrid2);
tableViewDS.DetailTables.Add(tableViewINS);
tableViewINS.Name = "tableViewINS";
// tableViewINS.DataKeyNames = new string[] { "DT_NAME", "DS_NAME", "INS_NAME", "PRJ_NAME", "DATA" };
tableViewINS.DataKeyNames = new string[] {"DT_NAME", "DS_NAME", "INS_NAME", "PRJ_NAME"};
// tableViewINS.DataSource = GetDataTable(dtUserData, "INS");
tableViewINS.Width = Unit.Percentage(100);
GridRelationFields relationFields1 = new GridRelationFields();
tableViewINS.ParentTableRelation.Add(relationFields1);
relationFields1.MasterKeyField = "DT_NAME";
relationFields1.DetailKeyField = "DT_NAME";
GridRelationFields relationFields2 = new GridRelationFields();
tableViewINS.ParentTableRelation.Add(relationFields2);
relationFields2.MasterKeyField = "DS_NAME";
relationFields2.DetailKeyField = "DS_NAME";
GridRelationFields relationFields3 = new GridRelationFields();
tableViewINS.ParentTableRelation.Add(relationFields3);
relationFields3.MasterKeyField = "INS_NAME";
relationFields3.DetailKeyField = "INS_NAME";
//tableViewDS.DetailTables.Add(tableViewINS);
boundColumn = new GridBoundColumn();
tableViewINS.Columns.Add(boundColumn);
boundColumn.DataField = "PRJ_NAME";
}
Thanks
Now a very strange thing is happening and on reading various posts here, I realized that others faced the same problem too.
I have 4 levels of hierarchy and I create my Hierarchical RadGrid on page_load and I followed each and every thing that I had to for the page_load way of doing it
Now the thing is that if I use RadAjaxManager1 and don't postback and use view state to show various nodes of the grid, it doesn't do anything for level 3 and 4. i.e I would stop at level 2 and I won't see anything for levels 3 and 4.
To check what's going on wrong, on postBack, I call the same RadGrid creating function to do each and every thing all over again and when i click on + of node 2 then it says
Parent table relations set, but no correspoding data-key name found
However, I have my relations well in place but it is somehow not copying it to the next server submit i.e post back
So i added parent-child relations for the 3rd and 4th level in the detailTableDataBind function something like this
e.DetailTableView.ParentTableRelation[0].DetailKeyField = "DT_NAME";
e.DetailTableView.ParentTableRelation[0].MasterKeyField = "DT_NAME";
and it works fine.
However, if I don't call the Grid Generating function on postback and try to use the viewstate value of the grid using RadAjaxManager1, it does the same i.e. doesn't show up anything for the 3rd and the 4th level.
Can you please tell me whats going on here.
Please see a copy of my RidGenerating function (first 3 levels only, 3 doesn't show up in the grid)
protected void Page_Load(object sender, EventArgs e)
{
RadGrid2 = new RadGrid();
RadGrid2.ID = "RadGrid2";
this.PlaceHolder1.Controls.Add(RadGrid2);
if (!IsPostBack)
{
XmlNodeUserSelectedData = getData(userName, gadgetID, UWI);
dtUserData = objCommon.MakeDataTable_SelectedUser(XmlNodeUserSelectedData, "Data");
ViewState["DataTable_SelectedUserData"] = dtUserData;
ViewState["XmlNodeUserSelectedData"] = XmlNodeUserSelectedData.OuterXml.ToString(); //converted to string because xmlnode can't be passed in view state
GenerateGrid(dtUserData);
}
}
-----------------------------------------------------
--------------------------------------------------------
private void GenerateGrid(DataTable dtUserData)
{
//RadGrid2.MasterTableView.DataSource = GetDataTable(dtUserData, "DT");
RadGrid2.ID = "RadGrid2";
GridRelationFields relationFields;
RadGrid2.NeedDataSource += new GridNeedDataSourceEventHandler(this.RadGrid2_NeedDataSource);
RadGrid2.DetailTableDataBind += new GridDetailTableDataBindEventHandler(this.RadGrid2_DetailTableDataBind);
RadGrid2.ItemDataBound += new GridItemEventHandler(RadGrid2_ItemDataBound);
//RadGrid2.PreRender += new EventHandler(RadGrid2_PreRender);
RadGrid2.Skin = "Office2007";
RadGrid2.Width = Unit.Percentage(100);
RadGrid2.PageSize = 12;
RadGrid2.AllowPaging = true;
//RadGrid2.ClientSettings.Scrolling.AllowScroll = true;
//RadGrid2.ClientSettings.Scrolling.ScrollHeight = 10;
RadGrid2.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;
RadGrid2.AutoGenerateColumns = false;
RadGrid2.GroupingEnabled = true;
RadGrid2.EnableAJAX = true;
RadGrid2.ShowGroupPanel = true;
RadGrid2.MasterTableView.Name = "tableViewDT";
RadGrid2.MasterTableView.HierarchyLoadMode = GridChildLoadMode.ServerBind;
RadGrid2.MasterTableView.HierarchyDefaultExpanded = false;
RadGrid2.MasterTableView.PageSize = 12;
RadGrid2.MasterTableView.Width = Unit.Percentage(100);
//RadGrid2.MasterTableView.DataKeyNames = new string[] { "DT_NAME", "DS_NAME", "INS_NAME", "PRJ_NAME", "DATA" };
RadGrid2.MasterTableView.DataKeyNames = new string[] { "DT_NAME", "DS_NAME" };
GridBoundColumn boundColumn = new GridBoundColumn();
RadGrid2.MasterTableView.Columns.Add(boundColumn);
boundColumn.DataField = "DS_NAME";
///////////////////////////////////////////////////////////////////////////////////////
///////////////////DEFINE GROUPBY EXPRESSION FOR GRID MASTER TABLE VIEW/////////////////
///////////////////////////////////////////////////////////////////////////////////////
GridGroupByExpression expression = new GridGroupByExpression();
GridGroupByField gridGroupByField = new GridGroupByField();
// SelectFields values (appear in header)
gridGroupByField = new GridGroupByField();
gridGroupByField.FieldName = "DT_NAME";
gridGroupByField.HeaderText = "Data Type";
//gridGroupByField.FormatString = "<strong>{0}</strong>";
gridGroupByField.FormatString = "{0}";
expression.SelectFields.Add(gridGroupByField);
//GroupByFields values (group data)
gridGroupByField = new GridGroupByField();
gridGroupByField.FieldName = "DT_NAME";
expression.GroupByFields.Add(gridGroupByField);
RadGrid2.MasterTableView.GroupByExpressions.Add(expression);
/////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////DEFINE DETAIL TABLE VIEW (tableViewDS) FOR THE MASTER TABLE VIEW///////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
//Add first and then set the properties (to make viewstate persist on post_back)
GridTableView tableViewDS = new GridTableView(RadGrid2);
RadGrid2.MasterTableView.DetailTables.Add(tableViewDS);
tableViewDS.Name = "tableViewDS";
tableViewDS.ID = "tableViewDS";
//tableViewDS.DataSource = GetDataTable(dtUserData, "DS");
//tableViewDS.DataKeyNames = new string[] { "DT_NAME", "DS_NAME", "INS_NAME", "PRJ_NAME", "DATA" };
tableViewDS.DataKeyNames = new string[] { "DT_NAME", "DS_NAME", "INS_NAME"};
tableViewDS.Width = Unit.Percentage(100);
relationFields = new GridRelationFields();
tableViewDS.ParentTableRelation.Add(relationFields);
relationFields.MasterKeyField = "DT_NAME";
relationFields.DetailKeyField = "DT_NAME";
relationFields = new GridRelationFields();
tableViewDS.ParentTableRelation.Add(relationFields);
relationFields.MasterKeyField = "DS_NAME";
relationFields.DetailKeyField = "DS_NAME";
//RadGrid2.MasterTableView.DetailTables.Add(tableViewDS);
boundColumn = new GridBoundColumn();
tableViewDS.Columns.Add(boundColumn);
boundColumn.DataField = "INS_NAME";
/////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////DEFINE DETAIL TABLE VIEW (tableViewINS) FOR THE tableViewDS///////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
//Add first and then set the properties (to make viewstate persist on post_back)
GridTableView tableViewINS = new GridTableView(RadGrid2);
tableViewDS.DetailTables.Add(tableViewINS);
tableViewINS.Name = "tableViewINS";
// tableViewINS.DataKeyNames = new string[] { "DT_NAME", "DS_NAME", "INS_NAME", "PRJ_NAME", "DATA" };
tableViewINS.DataKeyNames = new string[] {"DT_NAME", "DS_NAME", "INS_NAME", "PRJ_NAME"};
// tableViewINS.DataSource = GetDataTable(dtUserData, "INS");
tableViewINS.Width = Unit.Percentage(100);
GridRelationFields relationFields1 = new GridRelationFields();
tableViewINS.ParentTableRelation.Add(relationFields1);
relationFields1.MasterKeyField = "DT_NAME";
relationFields1.DetailKeyField = "DT_NAME";
GridRelationFields relationFields2 = new GridRelationFields();
tableViewINS.ParentTableRelation.Add(relationFields2);
relationFields2.MasterKeyField = "DS_NAME";
relationFields2.DetailKeyField = "DS_NAME";
GridRelationFields relationFields3 = new GridRelationFields();
tableViewINS.ParentTableRelation.Add(relationFields3);
relationFields3.MasterKeyField = "INS_NAME";
relationFields3.DetailKeyField = "INS_NAME";
//tableViewDS.DetailTables.Add(tableViewINS);
boundColumn = new GridBoundColumn();
tableViewINS.Columns.Add(boundColumn);
boundColumn.DataField = "PRJ_NAME";
}
Thanks
0
Hi Jas,
In order to research the problem further, I would request to send me a simple working version of your project (illustrating the depicted behavior) in order to debug it locally and give you more appropriate answer. You can attach the project to a regular support ticket.
Best regards,
Daniel
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
In order to research the problem further, I would request to send me a simple working version of your project (illustrating the depicted behavior) in order to debug it locally and give you more appropriate answer. You can attach the project to a regular support ticket.
Best regards,
Daniel
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

Jas
Top achievements
Rank 1
answered on 18 Jul 2008, 09:02 PM
Hi Daniel,
I don't know how to provide you with the exact working model because my data comes from a webservice and other 3rd party components.
The code that I sent you is pretty much what it takes to build a grid.
Also, I can't open a support ticket somehow. I don't know what does it take to do that.
Also, if I load my Hierarchical grid on every single post back, the paging gives some weird results and so does the sorting.
All columns get duplicated as soon as the page command or sort command is fired. Do I need to handle these events and do something special here.
At this point of time, I am in no position to say that hierarchical Radgrids are reliable for the following reasons.
1. View state doesn't get copied at some levels.
2. Duplication of child rows and columns on sort and page command.
What all code do you need to debug my problem ?
I can't send you code for my data service and all that. However I can send you my .cs code.
Please let me know how can I coordinate with you guys to get my problem fixed. Based on what I show here in next 1 week, we'll be taking a decision to actually buy a license for your tools.
So let me know how do you guys want to go about it.
Thanks
I don't know how to provide you with the exact working model because my data comes from a webservice and other 3rd party components.
The code that I sent you is pretty much what it takes to build a grid.
Also, I can't open a support ticket somehow. I don't know what does it take to do that.
Also, if I load my Hierarchical grid on every single post back, the paging gives some weird results and so does the sorting.
All columns get duplicated as soon as the page command or sort command is fired. Do I need to handle these events and do something special here.
At this point of time, I am in no position to say that hierarchical Radgrids are reliable for the following reasons.
1. View state doesn't get copied at some levels.
2. Duplication of child rows and columns on sort and page command.
What all code do you need to debug my problem ?
I can't send you code for my data service and all that. However I can send you my .cs code.
Please let me know how can I coordinate with you guys to get my problem fixed. Based on what I show here in next 1 week, we'll be taking a decision to actually buy a license for your tools.
So let me know how do you guys want to go about it.
Thanks
0

Harpreet
Top achievements
Rank 1
answered on 22 Jul 2008, 04:42 AM
even i am facing the same problem
0

Hary
Top achievements
Rank 1
answered on 22 Jul 2008, 05:23 AM
hello
is there any way you can help me out without raising a support ticket.
i tried but it doesn't allow me to add one.
find my code pasted below:-
----------------------------------------
---------------------------------------
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
using Telerik.WebControls;
using System.IO;
public partial class Default2 : System.Web.UI.Page
{
int RowCountDT = 0;
int RowCountDS = 0;
int RowCountINS = 0;
RadGrid RadGrid2;
common objCommon = new common();
public XmlNode XmlNodeUserSelectedData;
DataTable dtUserData;
protected void Page_Load(object sender, EventArgs e)
{
RadGrid2 = new RadGrid();
RadGrid2.ID = "RadGrid2";
this.PlaceHolder1.Controls.Clear();
this.PlaceHolder1.Controls.Add(RadGrid2);
if (!IsPostBack)
{
XmlNodeUserSelectedData = getData(userName, gadgetID, UWI);
dtUserData = objCommon.MakeDataTable_SelectedUser(XmlNodeUserSelectedData, "Data");
ViewState["DataTable_SelectedUserData"] = dtUserData;
ViewState["XmlNodeUserSelectedData"] = XmlNodeUserSelectedData.OuterXml.ToString(); //converted to string because xmlnode can't be passed in view state
GenerateGrid(dtUserData);
}
else
{
dtUserData = (DataTable)ViewState["DataTable_SelectedUserData"];
XmlDocument tempXml = new XmlDocument();
tempXml.LoadXml((string)ViewState["XmlNodeUserSelectedData"]);
XmlNodeUserSelectedData = tempXml;
XmlNodeUserSelectedData = XmlNodeUserSelectedData.ChildNodes[0];
GenerateGrid(dtUserData);
}
RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadGrid2, RadGrid2);
}
private void GenerateGrid(DataTable dtUserData)
{
///////////////////////////////////////////////////////////////////
///////////////////DEFINE GRID GENERAL PROPERTIES/////////////////
/////////////////////////////////////////////////////////////////
//RadGrid2.MasterTableView.DataSource = GetDataTable(dtUserData, "DT");
RadGrid2.ID = "RadGrid2";
GridRelationFields relationFields;
RadGrid2.NeedDataSource += new GridNeedDataSourceEventHandler(this.RadGrid2_NeedDataSource);
RadGrid2.DetailTableDataBind += new GridDetailTableDataBindEventHandler(this.RadGrid2_DetailTableDataBind);
RadGrid2.SortCommand +=new GridSortCommandEventHandler(RadGrid2_SortCommand);
RadGrid2.ItemDataBound += new GridItemEventHandler(RadGrid2_ItemDataBound);
//RadGrid2.PreRender += new EventHandler(RadGrid2_PreRender);
RadGrid2.Skin = "Web20";
RadGrid2.Width = Unit.Percentage(80);
RadGrid2.BorderStyle = BorderStyle.Solid;
RadGrid2.PageSize = 3;
// RadGrid2.AllowSorting = true;
RadGrid2.AllowPaging = false;
//RadGrid2.ClientSettings.Scrolling.AllowScroll = true;
//RadGrid2.ClientSettings.Scrolling.ScrollHeight = 10;
RadGrid2.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;
RadGrid2.AutoGenerateColumns = false;
RadGrid2.GroupingEnabled = true;
RadGrid2.EnableAJAX = true;
RadGrid2.ShowGroupPanel = true;
RadGrid2.MasterTableView.Name = "tableViewDT";
RadGrid2.MasterTableView.HierarchyLoadMode = GridChildLoadMode.ServerBind;
RadGrid2.MasterTableView.HierarchyDefaultExpanded = false;
RadGrid2.MasterTableView.PageSize = 3;
RadGrid2.MasterTableView.Width = Unit.Percentage(100);
RadGrid2.MasterTableView.ShowHeader = false;
//RadGrid2.MasterTableView.DataKeyNames = new string[] { "DT_NAME", "DS_NAME", "INS_NAME", "PRJ_NAME", "DATA" };
RadGrid2.MasterTableView.DataKeyNames = new string[] { "DT_NAME", "DS_NAME" };
RadGrid2.MasterTableView.Width = Unit.Percentage(80);
RadGrid2.MasterTableView.BorderStyle = BorderStyle.Solid;
GridBoundColumn boundColumn = new GridBoundColumn();
RadGrid2.MasterTableView.Columns.Add(boundColumn);
boundColumn.DataField = "DS_NAME";
RadGrid2.MasterTableView.BorderStyle= BorderStyle.None;
///////////////////////////////////////////////////////////////////////////////////////
///////////////////DEFINE GROUPBY EXPRESSION FOR GRID MASTER TABLE VIEW/////////////////
///////////////////////////////////////////////////////////////////////////////////////
GridGroupByExpression expression = new GridGroupByExpression();
GridGroupByField gridGroupByField = new GridGroupByField();
// SelectFields values (appear in header)
gridGroupByField = new GridGroupByField();
gridGroupByField.FieldName = "DT_NAME";
gridGroupByField.HeaderText = "Data Type";
//gridGroupByField.FormatString = "<strong>{0}</strong>";
gridGroupByField.FormatString = "{0}";
expression.SelectFields.Add(gridGroupByField);
//GroupByFields values (group data)
gridGroupByField = new GridGroupByField();
gridGroupByField.FieldName = "DT_NAME";
expression.GroupByFields.Add(gridGroupByField);
RadGrid2.MasterTableView.GroupByExpressions.Add(expression);
/////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////DEFINE DETAIL TABLE VIEW (tableViewDS) FOR THE MASTER TABLE VIEW///////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
//Add first and then set the properties (to make viewstate persist on post_back)
GridTableView tableViewDS = new GridTableView(RadGrid2);
RadGrid2.MasterTableView.DetailTables.Add(tableViewDS);
tableViewDS.ShowHeader = false;
tableViewDS.Name = "tableViewDS";
tableViewDS.ID = "tableViewDS";
tableViewDS.BorderStyle = BorderStyle.None;
//tableViewDS.DataSource = GetDataTable(dtUserData, "DS");
//tableViewDS.DataKeyNames = new string[] { "DT_NAME", "DS_NAME", "INS_NAME", "PRJ_NAME", "DATA" };
tableViewDS.DataKeyNames = new string[] { "DT_NAME", "DS_NAME", "INS_NAME"};
tableViewDS.Width = Unit.Percentage(100);
relationFields = new GridRelationFields();
tableViewDS.ParentTableRelation.Add(relationFields);
relationFields.MasterKeyField = "DT_NAME";
relationFields.DetailKeyField = "DT_NAME";
relationFields = new GridRelationFields();
tableViewDS.ParentTableRelation.Add(relationFields);
relationFields.MasterKeyField = "DS_NAME";
relationFields.DetailKeyField = "DS_NAME";
//RadGrid2.MasterTableView.DetailTables.Add(tableViewDS);
boundColumn = new GridBoundColumn();
tableViewDS.Columns.Add(boundColumn);
boundColumn.DataField = "INS_NAME";
/////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////DEFINE DETAIL TABLE VIEW (tableViewINS) FOR THE tableViewDS///////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
//Add first and then set the properties (to make viewstate persist on post_back)
GridTableView tableViewINS = new GridTableView(RadGrid2);
tableViewDS.DetailTables.Add(tableViewINS);
tableViewINS.ShowHeader = false;
tableViewINS.Name = "tableViewINS";
// tableViewINS.DataKeyNames = new string[] { "DT_NAME", "DS_NAME", "INS_NAME", "PRJ_NAME", "DATA" };
tableViewINS.DataKeyNames = new string[] {"DT_NAME", "DS_NAME", "INS_NAME", "PRJ_NAME"};
// tableViewINS.DataSource = GetDataTable(dtUserData, "INS");
tableViewINS.Width = Unit.Percentage(100);
tableViewINS.BorderStyle = BorderStyle.None;
GridRelationFields relationFields1 = new GridRelationFields();
tableViewINS.ParentTableRelation.Add(relationFields1);
relationFields1.MasterKeyField = "DT_NAME";
relationFields1.DetailKeyField = "DT_NAME";
GridRelationFields relationFields2 = new GridRelationFields();
tableViewINS.ParentTableRelation.Add(relationFields2);
relationFields2.MasterKeyField = "DS_NAME";
relationFields2.DetailKeyField = "DS_NAME";
GridRelationFields relationFields3 = new GridRelationFields();
tableViewINS.ParentTableRelation.Add(relationFields3);
relationFields3.MasterKeyField = "INS_NAME";
relationFields3.DetailKeyField = "INS_NAME";
//tableViewDS.DetailTables.Add(tableViewINS);
boundColumn = new GridBoundColumn();
tableViewINS.Columns.Add(boundColumn);
boundColumn.DataField = "PRJ_NAME";
/////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////DEFINE DETAIL TABLE VIEW (tableViewPrj) FOR THE tableViewINS////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
//Add first and then set the properties (to make viewstate persist on post_back)
GridTableView tableViewPRJ = new GridTableView(RadGrid2);
tableViewINS.DetailTables.Add(tableViewPRJ);
tableViewPRJ.ShowHeader = false;
tableViewPRJ.Name = "tableViewPRJ";
//tableViewPRJ.DataSource = GetDataTable(dtUserData, "PRJ");
tableViewPRJ.DataKeyNames = new string[] { "DT_NAME", "DS_NAME", "INS_NAME", "PRJ_NAME", "DATA" };
tableViewPRJ.Width = Unit.Percentage(100);
tableViewPRJ.BorderStyle = BorderStyle.None;
relationFields = new GridRelationFields();
tableViewPRJ.ParentTableRelation.Add(relationFields);
relationFields.MasterKeyField = "DT_NAME";
relationFields.DetailKeyField = "DT_NAME";
relationFields = new GridRelationFields();
tableViewPRJ.ParentTableRelation.Add(relationFields);
relationFields.MasterKeyField = "DS_NAME";
relationFields.DetailKeyField = "DS_NAME";
relationFields = new GridRelationFields();
tableViewPRJ.ParentTableRelation.Add(relationFields);
relationFields.MasterKeyField = "INS_NAME";
relationFields.DetailKeyField = "INS_NAME";
relationFields = new GridRelationFields();
tableViewPRJ.ParentTableRelation.Add(relationFields);
relationFields.MasterKeyField = "PRJ_NAME";
relationFields.DetailKeyField = "PRJ_NAME";
boundColumn = new GridBoundColumn();
tableViewPRJ.Columns.Add(boundColumn);
boundColumn.DataField = "DATA";
}
protected void RadGrid2_SortCommand(object sender, GridSortCommandEventArgs e)
{
}
private XmlNode getData(string userName, string gadgetID, string UWI)
{
XmlNode nodeUserData;
ewellDA objewellDA = new ewellDA();
nodeUserData = objewellDA.getData(userName, gadgetID, UWI);
return nodeUserData;
}
protected void RadGrid2_PreRender(object sender, EventArgs e)
{
foreach (GridGroupByExpression exp in RadGrid2.MasterTableView.GroupByExpressions)
{
exp.SelectFields.FindByName("DT_NAME").HeaderValueSeparator = string.Empty ;
}
// RadGrid2.Rebind();
}
protected void RadGrid2_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
if (!e.IsFromDetailTable)
{
RadGrid2.BorderStyle = BorderStyle.None;
RadGrid2.DataSource = GetDataTable(dtUserData, "DT");
}
}
protected void RadGrid2_DetailTableDataBind(object source, Telerik.WebControls.GridDetailTableDataBindEventArgs e)
{
GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
e.DetailTableView.BorderStyle = BorderStyle.None;
switch (e.DetailTableView.Name)
{
case "tableViewDS":
{
e.DetailTableView.ParentTableRelation[0].DetailKeyField = "DT_NAME";
e.DetailTableView.ParentTableRelation[0].MasterKeyField = "DT_NAME";
e.DetailTableView.ParentTableRelation[1].DetailKeyField = "DS_NAME";
e.DetailTableView.ParentTableRelation[1].MasterKeyField = "DS_NAME";
e.DetailTableView.DataSource = GetDataTable(dtUserData, "DS");
break;
}
case "tableViewINS":
{
e.DetailTableView.ParentTableRelation[0].DetailKeyField = "DT_NAME";
e.DetailTableView.ParentTableRelation[0].MasterKeyField = "DT_NAME";
e.DetailTableView.ParentTableRelation[1].DetailKeyField = "DS_NAME";
e.DetailTableView.ParentTableRelation[1].MasterKeyField = "DS_NAME";
e.DetailTableView.ParentTableRelation[2].DetailKeyField = "INS_NAME";
e.DetailTableView.ParentTableRelation[2].MasterKeyField = "INS_NAME";
e.DetailTableView.DataSource = GetDataTable(dtUserData, "INS");
break;
}
case "tableViewPRJ":
{
e.DetailTableView.ParentTableRelation[0].DetailKeyField = "DT_NAME";
e.DetailTableView.ParentTableRelation[0].MasterKeyField = "DT_NAME";
e.DetailTableView.ParentTableRelation[1].DetailKeyField = "DS_NAME";
e.DetailTableView.ParentTableRelation[1].MasterKeyField = "DS_NAME";
e.DetailTableView.ParentTableRelation[2].DetailKeyField = "INS_NAME";
e.DetailTableView.ParentTableRelation[2].MasterKeyField = "INS_NAME";
e.DetailTableView.ParentTableRelation[3].DetailKeyField = "PRJ_NAME";
e.DetailTableView.ParentTableRelation[3].MasterKeyField = "PRJ_NAME";
e.DetailTableView.DataSource = GetDataTable(dtUserData, "PRJ");
break;
}
}
}
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
{
string DT_NAME;
string DS_NAME;
string INS_NAME;
string PRJ_NAME;
string DATA;
string dataXml="";
// bool dataFound = false;
ArrayList compareText = new ArrayList();
if (e.Item is GridHeaderItem)
{
e.Item.BorderStyle = BorderStyle.None;
e.Item.BackColor = System.Drawing.Color.White;
//e.Item.BorderColor = System.Drawing.Color.BlanchedAlmond;
}
if (e.Item is GridGroupHeaderItem) // hyperlinks for DataType groups
// click and see report for all
// data stores under that DataType
{
e.Item.Expanded = false;
GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item;
string[] groupText = new string[2];
if (item.DataCell.Text.ToString().Contains(":"))
groupText = item.DataCell.Text.ToString().Split(':');
else
{
return;
}
//XmlNodeUserSelectedData
// query dtUserData for DATA item for the current DT_NAME
// make an xml string these DATA items
compareText.Add(groupText[1].Trim());
dataXml = gridDataHierarchyWise("DT", compareText );
if (dataXml != "" && dataXml != null)
{
Session["DATA_DT"] = "<OSP>" + dataXml + "</OSP>";
// dataXml = "<OSPDataStoreDetails>" + dataXml + "</OSPDataStoreDetails>";
item.DataCell.Text = "<a href='Default3.aspx?level=DT' target='_blank'>" + groupText[1] + " </a>";
item.DataCell.ToolTip = "click to view data from all selected Data Stores.";
}
else
{
item.DataCell.Text = groupText[1];
item.DataCell.ToolTip = "No Data Available";
}
}
if (e.Item is GridDataItem)
{
if (e.Item.OwnerTableView.Name.ToString() == "tableViewDT") // for DataStore Node
{
//get data for current Data Store and Data Type combination
DT_NAME = ((DataTable)(e.Item.OwnerTableView.DataSource)).Rows[RowCountDT]["DT_NAME"].ToString();
DS_NAME = ((DataTable)(e.Item.OwnerTableView.DataSource)).Rows[RowCountDT]["DS_NAME"].ToString();
//DT_NAME = e.Item.OwnerTableView.DataKeyValues[0]["DT_NAME"].ToString();
//DS_NAME = e.Item.OwnerTableView.DataKeyValues[0]["DS_NAME"].ToString();
RowCountDT++;
compareText.Add(DT_NAME.Trim());
compareText.Add(DS_NAME.Trim());
dataXml = gridDataHierarchyWise("DS", compareText);
if (dataXml != "" && dataXml != null)
{
// dataXml = "<OSPDataStoreDetails>" + dataXml + "</OSPDataStoreDetails>";
Session["DATA_DS"] = "<OSP>" + dataXml + "</OSP>";
GridDataItem item1 = (GridDataItem)e.Item;
item1["DS_NAME"].Text = "<a href='Default3.aspx?level=DS' target='_blank'>" + DS_NAME + " </a>";
item1.ToolTip = "click to view data from all selected Installations.";
}
else
{
GridDataItem item1 = (GridDataItem)e.Item;
item1["DS_NAME"].Text = DS_NAME ;
e.Item.ToolTip = "No Data Available";
}
}
else if (e.Item.OwnerTableView.Name.ToString() == "tableViewDS") // for Installation Node
{
//get data for current Data Store and Data Type combination
DT_NAME = e.Item.OwnerTableView.DataKeyValues[0]["DT_NAME"].ToString();
DS_NAME = e.Item.OwnerTableView.DataKeyValues[0]["DS_NAME"].ToString();
INS_NAME = e.Item.OwnerTableView.DataKeyValues[0]["INS_NAME"].ToString();
//DT_NAME = ((DataTable)(e.Item.OwnerTableView.DataSource)).Rows[RowCountDS]["DT_NAME"].ToString();
//DS_NAME = ((DataTable)(e.Item.OwnerTableView.DataSource)).Rows[RowCountDS]["DS_NAME"].ToString();
//INS_NAME = ((DataTable)(e.Item.OwnerTableView.DataSource)).Rows[RowCountDS]["INS_NAME"].ToString();
RowCountDS++;
compareText.Add(DT_NAME.Trim());
compareText.Add(DS_NAME.Trim());
compareText.Add(INS_NAME.Trim());
dataXml = gridDataHierarchyWise("INS", compareText);
if (dataXml != "" && dataXml != null)
{
//dataXml = "<OSPDataStoreDetails>" + dataXml + "</OSPDataStoreDetails>";
Session["DATA_INS"] = "<OSP>" + dataXml + "</OSP>";
GridDataItem item1 = (GridDataItem)e.Item;
item1["INS_NAME"].Text = "<a href='Default3.aspx?level=INS' target='_blank'>" + INS_NAME + " </a>";
item1.ToolTip = "click to view data from all selected Projects.";
}
else
{
e.Item.ToolTip = "No Data Available";
}
}
else if (e.Item.OwnerTableView.Name.ToString() == "tableViewINS") // for Installation Node
{
//get data for current Data Store and Data Type combination
DT_NAME = e.Item.OwnerTableView.DataKeyValues[RowCountINS]["DT_NAME"].ToString();
DS_NAME = e.Item.OwnerTableView.DataKeyValues[RowCountINS]["DS_NAME"].ToString();
INS_NAME = e.Item.OwnerTableView.DataKeyValues[RowCountINS]["INS_NAME"].ToString();
PRJ_NAME = e.Item.OwnerTableView.DataKeyValues[RowCountINS]["PRJ_NAME"].ToString();
/* DT_NAME = ((DataTable)(e.Item.OwnerTableView.DataSource)).Rows[RowCountINS]["DT_NAME"].ToString();
DS_NAME = ((DataTable)(e.Item.OwnerTableView.DataSource)).Rows[RowCountINS]["DS_NAME"].ToString();
INS_NAME = ((DataTable)(e.Item.OwnerTableView.DataSource)).Rows[RowCountINS]["INS_NAME"].ToString();
PRJ_NAME = ((DataTable)(e.Item.OwnerTableView.DataSource)).Rows[RowCountINS]["PRJ_NAME"].ToString();
*/
RowCountINS++;
compareText.Add(DT_NAME.Trim());
compareText.Add(DS_NAME.Trim());
compareText.Add(INS_NAME.Trim());
compareText.Add(PRJ_NAME.Trim());
dataXml = gridDataHierarchyWise("PRJ", compareText);
if (dataXml != "" && dataXml != null)
{
//dataXml = "<OSPDataStoreDetails>" + dataXml + "</OSPDataStoreDetails>";
Session["DATA_PRJ"] = "<OSP>" + dataXml + "</OSP>";
GridDataItem item1 = (GridDataItem)e.Item;
item1["PRJ_NAME"].Text = "<a href='Default3.aspx?level=PRJ' target='_blank'>" + PRJ_NAME + " </a>";
item1.ToolTip = "click to view data for this project.";
}
else
{
e.Item.ToolTip = "No Data Available";
}
}
else if (e.Item.OwnerTableView.Name.ToString() == "tableViewPRJ")
{
DT_NAME = e.Item.OwnerTableView.DataKeyValues[0]["DT_NAME"].ToString();
DS_NAME = e.Item.OwnerTableView.DataKeyValues[0]["DS_NAME"].ToString();
INS_NAME = e.Item.OwnerTableView.DataKeyValues[0]["INS_NAME"].ToString();
PRJ_NAME = e.Item.OwnerTableView.DataKeyValues[0]["PRJ_NAME"].ToString();
DATA = e.Item.OwnerTableView.DataKeyValues[0]["DATA"].ToString(); // hyperlink column data
XmlDocument myXmlDoc = new XmlDocument();
myXmlDoc.LoadXml(DATA);
string errorCode;
int dataRowCount = 0;
GridDataItem item1 = (GridDataItem)e.Item;
if (DATA.Substring(1, 9).ToUpper() == "EXCEPTION")
{
errorCode = (myXmlDoc.SelectSingleNode("/Exception/Code")).InnerText.ToString(); ;
item1["DATA"].Text = "Error Occured (Eror Code: " + errorCode + ")";
}
else
{
XmlNode DVNode = myXmlDoc.SelectSingleNode("/Data/DataValue");
if (DVNode.HasChildNodes)
{
dataRowCount = DVNode.ChildNodes.Count;
Session["DATA_DATA"] = "<OSP><OSPDataStoreDetails><OSPDataStore type='" + DS_NAME + "'><OSPDataStoreInstallation name='" + INS_NAME + "'><OSPProject name='" + PRJ_NAME + "'><OSPDataType name='" + DT_NAME + "'>" + DATA + "</OSPDataType></OSPProject> </OSPDataStoreInstallation></OSPDataStore></OSPDataStoreDetails></OSP>";
item1["DATA"].Text = "<a href='Default3.aspx?level=DATA' target='_blank'>" + dataRowCount + " record(s) available</a>";
}
else
{
item1["DATA"].Text = "Data not availabe";
}
}
}
}
else
{
}
}
private string gridDataHierarchyWise(string level, ArrayList compareText)
{
string dataXml="";
bool dataFound = false;
XmlNode NodesDS = XmlNodeUserSelectedData.ChildNodes[0].ChildNodes[0]; // points to all OSPDataStore nodes
foreach (XmlNode NodeDS in NodesDS) // points to all OSPDataStore nodes
{
//XmlNode NodeINS = NodeDS.ChildNodes[0]; // points to OSPDataStoreInstallation node under OSPDataStore node
// XmlNode NodePRJ = NodeDS.ChildNodes[0].ChildNodes[0]; // points to OSPProject node under OSPDataStore node
//XmlNode NodeDT = NodeDS.ChildNodes[0].ChildNodes[0].ChildNodes[0]; // points to OSPDataType node under OSPDataStore node
//XmlNode NodeINS ;
//XmlNode NodePRJ;
//XmlNode NodeDT;
switch (level)
{
case ("DT"):
{
string DT_NAME = (string)compareText[0];
//check the value of OSP DataType node for current OSPDataStore
foreach (XmlNode NodeINS in NodeDS)
{
foreach (XmlNode NodePRJ in NodeINS)
{
foreach (XmlNode NodeDT in NodePRJ)
{
if (NodeDT.Attributes["name"].Value.ToString().Trim() == DT_NAME)
{
//now check if this datastore has data by checking if DataValue node has childnodes or not
XmlNode tempNode = NodeDT.ChildNodes[0];
//return only when there is atleast one datastore with values
//if there's atleast one datastore with values, then others would display the
// error message. If all are erroneous then don't send back any data and simply return no data available
if (tempNode.Name.ToString() == "Data")// check if its an Exception or Data
{
XmlNode NodeDataValue = NodeDT.ChildNodes[0].ChildNodes[1];
if (NodeDataValue.HasChildNodes) //check if data available or not (i.e. Row node(s) present under DataValue node
{
//include this DataStore Outer xml in the final report string
// that needs to be passed on to the report page
dataFound = true;
}
}
//the following line needs to be revised
//this inludes all the datatypes under that Datastore
//which is wrong
// dataXml = dataXml + NodeDS.;
dataXml = dataXml + "<OSPDataStoreDetails><OSPDataStore ";
for (int i = 0; i < NodeDS.Attributes.Count; i++)
{
dataXml = dataXml + NodeDS.Attributes[i].Name.ToString() + "='" + NodeDS.Attributes[i].Value.ToString() + "' " ;
}
dataXml = dataXml + "><OSPDataStoreInstallation ";
for (int i = 0; i < NodeINS.Attributes.Count; i++)
{
dataXml = dataXml + NodeINS.Attributes[i].Name.ToString() + "='" + NodeINS.Attributes[i].Value.ToString() + "' ";
}
dataXml = dataXml + "><OSPProject ";
for (int i = 0; i < NodePRJ.Attributes.Count; i++)
{
dataXml = dataXml + NodePRJ.Attributes[i].Name.ToString() + "='" + NodePRJ.Attributes[i].Value.ToString() + "' ";
}
dataXml = dataXml + ">";
dataXml = dataXml + NodeDT.OuterXml.ToString();
dataXml = dataXml + "</OSPProject></OSPDataStoreInstallation></OSPDataStore></OSPDataStoreDetails>";
}
}
}
}
break;
}
case ("DS"):
{
string DT_NAME = (string)compareText[0];
string DS_NAME = (string)compareText[1];
//check the value of OSP DataType node for current OSPDataStore
foreach (XmlNode NodeINS in NodeDS)
{
foreach (XmlNode NodePRJ in NodeINS)
{
foreach (XmlNode NodeDT in NodePRJ)
{
if (NodeDS.Attributes["type"].Value.ToString().Trim() == DS_NAME && NodeDT.Attributes["name"].Value.ToString().Trim() == DT_NAME)
{
//now check if this datastore has data by checking if DataValue node has childnodes or not
XmlNode tempNode = NodeDT.ChildNodes[0];
if (tempNode.Name.ToString() == "Data") // check if its an Exception or Data
{
XmlNode NodeDataValue = NodeDT.ChildNodes[0].ChildNodes[1];
if (NodeDataValue.HasChildNodes) //check if data available or not (i.e. Row node(s) present under DataValue node
{
//include this DataStore Outer xml in the final report string
// that needs to be passed on to the report page
dataFound=true;
}
}
dataXml = dataXml + "<OSPDataStoreDetails><OSPDataStore ";
for (int i = 0; i < NodeDS.Attributes.Count; i++)
{
dataXml = dataXml + NodeDS.Attributes[i].Name.ToString() + "='" + NodeDS.Attributes[i].Value.ToString() + "' ";
}
dataXml = dataXml + "><OSPDataStoreInstallation ";
for (int i = 0; i < NodeINS.Attributes.Count; i++)
{
dataXml = dataXml + NodeINS.Attributes[i].Name.ToString() + "='" + NodeINS.Attributes[i].Value.ToString() + "' ";
}
dataXml = dataXml + "><OSPProject ";
for (int i = 0; i < NodePRJ.Attributes.Count; i++)
{
dataXml = dataXml + NodePRJ.Attributes[i].Name.ToString() + "='" + NodePRJ.Attributes[i].Value.ToString() + "' ";
}
dataXml = dataXml + ">";
dataXml = dataXml + NodeDT.OuterXml.ToString();
dataXml = dataXml + "</OSPProject></OSPDataStoreInstallation></OSPDataStore></OSPDataStoreDetails>";
}
}
}
}
break;
}
case ("INS"):
{
string DT_NAME = (string)compareText[0];
string DS_NAME = (string)compareText[1];
string INS_NAME = (string)compareText[2];
//check the value of OSP DataType node for current OSPDataStore
foreach (XmlNode NodeINS in NodeDS)
{
foreach (XmlNode NodePRJ in NodeINS)
{
foreach (XmlNode NodeDT in NodePRJ)
{
if (NodeDS.Attributes["type"].Value.ToString().Trim() == DS_NAME && NodeDT.Attributes["name"].Value.ToString().Trim() == DT_NAME && NodeINS.Attributes["name"].Value.ToString().Trim() == INS_NAME)
{
//now check if this datastore has data by checking if DataValue node has childnodes or not
XmlNode tempNode = NodeDT.ChildNodes[0];
if (tempNode.Name.ToString() == "Data") // check if its an Exception or Data
{
XmlNode NodeDataValue = NodeDT.ChildNodes[0].ChildNodes[1];
if (NodeDataValue.HasChildNodes) //check if data available or not (i.e. Row node(s) present under DataValue node
{
//include this DataStore Outer xml in the final report string
// that needs to be passed on to the report page
dataFound = true;
}
}
dataXml = dataXml + "<OSPDataStoreDetails><OSPDataStore ";
for (int i = 0; i < NodeDS.Attributes.Count; i++)
{
dataXml = dataXml + NodeDS.Attributes[i].Name.ToString() + "='" + NodeDS.Attributes[i].Value.ToString() + "' ";
}
dataXml = dataXml + "><OSPDataStoreInstallation ";
for (int i = 0; i < NodeINS.Attributes.Count; i++)
{
dataXml = dataXml + NodeINS.Attributes[i].Name.ToString() + "='" + NodeINS.Attributes[i].Value.ToString() + "' ";
}
dataXml = dataXml + "><OSPProject ";
for (int i = 0; i < NodePRJ.Attributes.Count; i++)
{
dataXml = dataXml + NodePRJ.Attributes[i].Name.ToString() + "='" + NodePRJ.Attributes[i].Value.ToString() + "' ";
}
dataXml = dataXml + ">";
dataXml = dataXml + NodeDT.OuterXml.ToString();
dataXml = dataXml + "</OSPProject></OSPDataStoreInstallation></OSPDataStore></OSPDataStoreDetails>";
}
}
}
}
break;
}
case ("PRJ"):
{
string DT_NAME = (string)compareText[0];
string DS_NAME = (string)compareText[1];
string INS_NAME = (string)compareText[2];
string PRJ_NAME = (string)compareText[3];
//check the value of OSP DataType node for current OSPDataStore
foreach (XmlNode NodeINS in NodeDS)
{
foreach (XmlNode NodePRJ in NodeINS)
{
foreach (XmlNode NodeDT in NodePRJ)
{
if (NodeDS.Attributes["type"].Value.ToString().Trim() == DS_NAME && NodeDT.Attributes["name"].Value.ToString().Trim() == DT_NAME && NodeINS.Attributes["name"].Value.ToString().Trim() == INS_NAME && NodePRJ.Attributes["name"].Value.ToString().Trim() == PRJ_NAME)
{
//now check if this datastore has data by checking if DataValue node has childnodes or not
XmlNode tempNode = NodeDT.ChildNodes[0];
if (tempNode.Name.ToString() == "Data") // check if its an Exception or Data
{
XmlNode NodeDataValue = NodeDT.ChildNodes[0].ChildNodes[1];
if (NodeDataValue.HasChildNodes) //check if data available or not (i.e. Row node(s) present under DataValue node
{
//include this DataStore Outer xml in the final report string
// that needs to be passed on to the report page
dataFound = true;
}
}
dataXml = dataXml + "<OSPDataStoreDetails><OSPDataStore ";
for (int i = 0; i < NodeDS.Attributes.Count; i++)
{
dataXml = dataXml + NodeDS.Attributes[i].Name.ToString() + "='" + NodeDS.Attributes[i].Value.ToString() + "' ";
}
dataXml = dataXml + "><OSPDataStoreInstallation ";
for (int i = 0; i < NodeINS.Attributes.Count; i++)
{
dataXml = dataXml + NodeINS.Attributes[i].Name.ToString() + "='" + NodeINS.Attributes[i].Value.ToString() + "' ";
}
dataXml = dataXml + "><OSPProject ";
for (int i = 0; i < NodePRJ.Attributes.Count; i++)
{
dataXml = dataXml + NodePRJ.Attributes[i].Name.ToString() + "='" + NodePRJ.Attributes[i].Value.ToString() + "' ";
}
dataXml = dataXml + ">";
dataXml = dataXml + NodeDT.OuterXml.ToString();
dataXml = dataXml + "</OSPProject></OSPDataStoreInstallation></OSPDataStore></OSPDataStoreDetails>";
}
}
}
}
break;
}
}
}
if (dataFound==false)
dataXml="";
return dataXml;
}
public DataTable GetDataTable(DataTable dtUserData, string level)
{
dtUserData.DefaultView.Sort = "DT_NAME, DS_NAME, INS_NAME, PRJ_NAME, DATA";
string old_DS = "";
string new_DS = "";
string old_DT = "";
string new_DT = "";
string old_INS = "";
string new_INS = "";
string old_PRJ = "";
string new_PRJ = "";
//string new_DATA = "";
DataTable myTable = new DataTable("tempDT");
DataColumn DT_NAME_Column;
DataColumn DS_NAME_Column;
DataColumn INS_NAME_Column;
DataColumn PRJ_NAME_Column;
DataColumn DATA_Column;
DataRow myRow;
DT_NAME_Column = new DataColumn();
DT_NAME_Column.DataType = System.Type.GetType("System.String");
DT_NAME_Column.ColumnName = "DT_NAME";
DT_NAME_Column.DefaultValue = "DT_NAME";
myTable.Columns.Add(DT_NAME_Column);
DS_NAME_Column = new DataColumn();
DS_NAME_Column.DataType = System.Type.GetType("System.String");
DS_NAME_Column.ColumnName = "DS_NAME";
DS_NAME_Column.DefaultValue = "DS_NAME";
myTable.Columns.Add(DS_NAME_Column);
INS_NAME_Column = new DataColumn();
INS_NAME_Column.DataType = System.Type.GetType("System.String");
INS_NAME_Column.ColumnName = "INS_NAME";
INS_NAME_Column.DefaultValue = "INS_NAME";
myTable.Columns.Add(INS_NAME_Column);
PRJ_NAME_Column = new DataColumn();
PRJ_NAME_Column.DataType = System.Type.GetType("System.String");
PRJ_NAME_Column.ColumnName = "PRJ_NAME";
PRJ_NAME_Column.DefaultValue = "PRJ_NAME";
myTable.Columns.Add(PRJ_NAME_Column);
DATA_Column = new DataColumn();
DATA_Column.DataType = System.Type.GetType("System.String");
DATA_Column.ColumnName = "DATA";
DATA_Column.DefaultValue = "DATA";
myTable.Columns.Add(DATA_Column);
if (level == "DT")
{
for (int i = 0; i < dtUserData.DefaultView.Count; i++)
{
new_DT = dtUserData.DefaultView[i]["DT_NAME"].ToString();
new_DS = dtUserData.DefaultView[i]["DS_NAME"].ToString();
// new_INS = dtUserData.DefaultView[i]["INS_NAME"].ToString();
//new_PRJ = dtUserData.DefaultView[i]["PRJ_NAME"].ToString();
// new_DATA = dtUserData.DefaultView[i]["DATA"].ToString();
if ((new_DT == old_DT) && (new_DS == old_DS))
{
}
else
{
myRow = myTable.NewRow();
myRow["DT_NAME"] = new_DT;
myRow["DS_NAME"] = new_DS;
// myRow["INS_NAME"] = new_INS;
// myRow["PRJ_NAME"] = new_PRJ;
// myRow["DATA"] = new_DATA;
myTable.Rows.Add(myRow);
old_DT = new_DT;
old_DS = new_DS;
}
}
}
else if (level == "DS")
{
for (int i = 0; i < dtUserData.DefaultView.Count; i++)
{
new_DT = dtUserData.DefaultView[i]["DT_NAME"].ToString();
new_DS = dtUserData.DefaultView[i]["DS_NAME"].ToString();
new_INS = dtUserData.DefaultView[i]["INS_NAME"].ToString();
// new_PRJ = dtUserData.DefaultView[i]["PRJ_NAME"].ToString();
// new_DATA = dtUserData.DefaultView[i]["DATA"].ToString();
if ((new_DT == old_DT) && (new_DS == old_DS) && (new_INS == old_INS))
{
}
else
{
myRow = myTable.NewRow();
myRow["DT_NAME"] = new_DT;
myRow["DS_NAME"] = new_DS;
myRow["INS_NAME"] = new_INS;
// myRow["PRJ_NAME"] = new_PRJ;
// myRow["DATA"] = new_DATA;
myTable.Rows.Add(myRow);
old_DT = new_DT;
old_DS = new_DS;
old_INS = new_INS;
}
}
}
else if (level == "INS")
{
for (int i = 0; i < dtUserData.DefaultView.Count; i++)
{
new_DT = dtUserData.DefaultView[i]["DT_NAME"].ToString();
new_DS = dtUserData.DefaultView[i]["DS_NAME"].ToString();
new_INS = dtUserData.DefaultView[i]["INS_NAME"].ToString();
new_PRJ = dtUserData.DefaultView[i]["PRJ_NAME"].ToString();
// new_DATA = dtUserData.DefaultView[i]["DATA"].ToString();
if ((new_DT == old_DT) && (new_DS == old_DS) && (new_INS == old_INS) && (new_PRJ == old_PRJ))
{
}
else
{
myRow = myTable.NewRow();
myRow["DT_NAME"] = new_DT;
myRow["DS_NAME"] = new_DS;
myRow["INS_NAME"] = new_INS;
myRow["PRJ_NAME"] = new_PRJ;
// myRow["DATA"] = new_DATA;
myTable.Rows.Add(myRow);
old_DT = new_DT;
old_DS = new_DS;
old_INS = new_INS;
old_PRJ = new_PRJ;
}
}
}
else if (level == "PRJ")
{
myTable = dtUserData ;
}
return myTable;
}
}
------------------------------------------
-------------------------------------------------
Again, this is a hierarchical grid for 4 level hierarchy
and it doesn't do anything after hierarchy level 2 because i loses track or viewstate for relations beween master-child tableviews from level 3 onwards.
If i keep submitting the page back to the server on every postback and keeping all the relations defined in the code for DetailTableBind function, it works fine.
However, paging and sorting doesn't work at all.
If i don't submit to the server on post back and take the shield on Ajax it doesn't work even if i put the relations in DetailTableViewBind function.
I have only 2 days left to submit my proposal and I think I've almost lost it.
Can you guys be of any help. buying a license depends on complete working of this piece
Thanks
is there any way you can help me out without raising a support ticket.
i tried but it doesn't allow me to add one.
find my code pasted below:-
----------------------------------------
---------------------------------------
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
using Telerik.WebControls;
using System.IO;
public partial class Default2 : System.Web.UI.Page
{
int RowCountDT = 0;
int RowCountDS = 0;
int RowCountINS = 0;
RadGrid RadGrid2;
common objCommon = new common();
public XmlNode XmlNodeUserSelectedData;
DataTable dtUserData;
protected void Page_Load(object sender, EventArgs e)
{
RadGrid2 = new RadGrid();
RadGrid2.ID = "RadGrid2";
this.PlaceHolder1.Controls.Clear();
this.PlaceHolder1.Controls.Add(RadGrid2);
if (!IsPostBack)
{
XmlNodeUserSelectedData = getData(userName, gadgetID, UWI);
dtUserData = objCommon.MakeDataTable_SelectedUser(XmlNodeUserSelectedData, "Data");
ViewState["DataTable_SelectedUserData"] = dtUserData;
ViewState["XmlNodeUserSelectedData"] = XmlNodeUserSelectedData.OuterXml.ToString(); //converted to string because xmlnode can't be passed in view state
GenerateGrid(dtUserData);
}
else
{
dtUserData = (DataTable)ViewState["DataTable_SelectedUserData"];
XmlDocument tempXml = new XmlDocument();
tempXml.LoadXml((string)ViewState["XmlNodeUserSelectedData"]);
XmlNodeUserSelectedData = tempXml;
XmlNodeUserSelectedData = XmlNodeUserSelectedData.ChildNodes[0];
GenerateGrid(dtUserData);
}
RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadGrid2, RadGrid2);
}
private void GenerateGrid(DataTable dtUserData)
{
///////////////////////////////////////////////////////////////////
///////////////////DEFINE GRID GENERAL PROPERTIES/////////////////
/////////////////////////////////////////////////////////////////
//RadGrid2.MasterTableView.DataSource = GetDataTable(dtUserData, "DT");
RadGrid2.ID = "RadGrid2";
GridRelationFields relationFields;
RadGrid2.NeedDataSource += new GridNeedDataSourceEventHandler(this.RadGrid2_NeedDataSource);
RadGrid2.DetailTableDataBind += new GridDetailTableDataBindEventHandler(this.RadGrid2_DetailTableDataBind);
RadGrid2.SortCommand +=new GridSortCommandEventHandler(RadGrid2_SortCommand);
RadGrid2.ItemDataBound += new GridItemEventHandler(RadGrid2_ItemDataBound);
//RadGrid2.PreRender += new EventHandler(RadGrid2_PreRender);
RadGrid2.Skin = "Web20";
RadGrid2.Width = Unit.Percentage(80);
RadGrid2.BorderStyle = BorderStyle.Solid;
RadGrid2.PageSize = 3;
// RadGrid2.AllowSorting = true;
RadGrid2.AllowPaging = false;
//RadGrid2.ClientSettings.Scrolling.AllowScroll = true;
//RadGrid2.ClientSettings.Scrolling.ScrollHeight = 10;
RadGrid2.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;
RadGrid2.AutoGenerateColumns = false;
RadGrid2.GroupingEnabled = true;
RadGrid2.EnableAJAX = true;
RadGrid2.ShowGroupPanel = true;
RadGrid2.MasterTableView.Name = "tableViewDT";
RadGrid2.MasterTableView.HierarchyLoadMode = GridChildLoadMode.ServerBind;
RadGrid2.MasterTableView.HierarchyDefaultExpanded = false;
RadGrid2.MasterTableView.PageSize = 3;
RadGrid2.MasterTableView.Width = Unit.Percentage(100);
RadGrid2.MasterTableView.ShowHeader = false;
//RadGrid2.MasterTableView.DataKeyNames = new string[] { "DT_NAME", "DS_NAME", "INS_NAME", "PRJ_NAME", "DATA" };
RadGrid2.MasterTableView.DataKeyNames = new string[] { "DT_NAME", "DS_NAME" };
RadGrid2.MasterTableView.Width = Unit.Percentage(80);
RadGrid2.MasterTableView.BorderStyle = BorderStyle.Solid;
GridBoundColumn boundColumn = new GridBoundColumn();
RadGrid2.MasterTableView.Columns.Add(boundColumn);
boundColumn.DataField = "DS_NAME";
RadGrid2.MasterTableView.BorderStyle= BorderStyle.None;
///////////////////////////////////////////////////////////////////////////////////////
///////////////////DEFINE GROUPBY EXPRESSION FOR GRID MASTER TABLE VIEW/////////////////
///////////////////////////////////////////////////////////////////////////////////////
GridGroupByExpression expression = new GridGroupByExpression();
GridGroupByField gridGroupByField = new GridGroupByField();
// SelectFields values (appear in header)
gridGroupByField = new GridGroupByField();
gridGroupByField.FieldName = "DT_NAME";
gridGroupByField.HeaderText = "Data Type";
//gridGroupByField.FormatString = "<strong>{0}</strong>";
gridGroupByField.FormatString = "{0}";
expression.SelectFields.Add(gridGroupByField);
//GroupByFields values (group data)
gridGroupByField = new GridGroupByField();
gridGroupByField.FieldName = "DT_NAME";
expression.GroupByFields.Add(gridGroupByField);
RadGrid2.MasterTableView.GroupByExpressions.Add(expression);
/////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////DEFINE DETAIL TABLE VIEW (tableViewDS) FOR THE MASTER TABLE VIEW///////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
//Add first and then set the properties (to make viewstate persist on post_back)
GridTableView tableViewDS = new GridTableView(RadGrid2);
RadGrid2.MasterTableView.DetailTables.Add(tableViewDS);
tableViewDS.ShowHeader = false;
tableViewDS.Name = "tableViewDS";
tableViewDS.ID = "tableViewDS";
tableViewDS.BorderStyle = BorderStyle.None;
//tableViewDS.DataSource = GetDataTable(dtUserData, "DS");
//tableViewDS.DataKeyNames = new string[] { "DT_NAME", "DS_NAME", "INS_NAME", "PRJ_NAME", "DATA" };
tableViewDS.DataKeyNames = new string[] { "DT_NAME", "DS_NAME", "INS_NAME"};
tableViewDS.Width = Unit.Percentage(100);
relationFields = new GridRelationFields();
tableViewDS.ParentTableRelation.Add(relationFields);
relationFields.MasterKeyField = "DT_NAME";
relationFields.DetailKeyField = "DT_NAME";
relationFields = new GridRelationFields();
tableViewDS.ParentTableRelation.Add(relationFields);
relationFields.MasterKeyField = "DS_NAME";
relationFields.DetailKeyField = "DS_NAME";
//RadGrid2.MasterTableView.DetailTables.Add(tableViewDS);
boundColumn = new GridBoundColumn();
tableViewDS.Columns.Add(boundColumn);
boundColumn.DataField = "INS_NAME";
/////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////DEFINE DETAIL TABLE VIEW (tableViewINS) FOR THE tableViewDS///////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
//Add first and then set the properties (to make viewstate persist on post_back)
GridTableView tableViewINS = new GridTableView(RadGrid2);
tableViewDS.DetailTables.Add(tableViewINS);
tableViewINS.ShowHeader = false;
tableViewINS.Name = "tableViewINS";
// tableViewINS.DataKeyNames = new string[] { "DT_NAME", "DS_NAME", "INS_NAME", "PRJ_NAME", "DATA" };
tableViewINS.DataKeyNames = new string[] {"DT_NAME", "DS_NAME", "INS_NAME", "PRJ_NAME"};
// tableViewINS.DataSource = GetDataTable(dtUserData, "INS");
tableViewINS.Width = Unit.Percentage(100);
tableViewINS.BorderStyle = BorderStyle.None;
GridRelationFields relationFields1 = new GridRelationFields();
tableViewINS.ParentTableRelation.Add(relationFields1);
relationFields1.MasterKeyField = "DT_NAME";
relationFields1.DetailKeyField = "DT_NAME";
GridRelationFields relationFields2 = new GridRelationFields();
tableViewINS.ParentTableRelation.Add(relationFields2);
relationFields2.MasterKeyField = "DS_NAME";
relationFields2.DetailKeyField = "DS_NAME";
GridRelationFields relationFields3 = new GridRelationFields();
tableViewINS.ParentTableRelation.Add(relationFields3);
relationFields3.MasterKeyField = "INS_NAME";
relationFields3.DetailKeyField = "INS_NAME";
//tableViewDS.DetailTables.Add(tableViewINS);
boundColumn = new GridBoundColumn();
tableViewINS.Columns.Add(boundColumn);
boundColumn.DataField = "PRJ_NAME";
/////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////DEFINE DETAIL TABLE VIEW (tableViewPrj) FOR THE tableViewINS////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
//Add first and then set the properties (to make viewstate persist on post_back)
GridTableView tableViewPRJ = new GridTableView(RadGrid2);
tableViewINS.DetailTables.Add(tableViewPRJ);
tableViewPRJ.ShowHeader = false;
tableViewPRJ.Name = "tableViewPRJ";
//tableViewPRJ.DataSource = GetDataTable(dtUserData, "PRJ");
tableViewPRJ.DataKeyNames = new string[] { "DT_NAME", "DS_NAME", "INS_NAME", "PRJ_NAME", "DATA" };
tableViewPRJ.Width = Unit.Percentage(100);
tableViewPRJ.BorderStyle = BorderStyle.None;
relationFields = new GridRelationFields();
tableViewPRJ.ParentTableRelation.Add(relationFields);
relationFields.MasterKeyField = "DT_NAME";
relationFields.DetailKeyField = "DT_NAME";
relationFields = new GridRelationFields();
tableViewPRJ.ParentTableRelation.Add(relationFields);
relationFields.MasterKeyField = "DS_NAME";
relationFields.DetailKeyField = "DS_NAME";
relationFields = new GridRelationFields();
tableViewPRJ.ParentTableRelation.Add(relationFields);
relationFields.MasterKeyField = "INS_NAME";
relationFields.DetailKeyField = "INS_NAME";
relationFields = new GridRelationFields();
tableViewPRJ.ParentTableRelation.Add(relationFields);
relationFields.MasterKeyField = "PRJ_NAME";
relationFields.DetailKeyField = "PRJ_NAME";
boundColumn = new GridBoundColumn();
tableViewPRJ.Columns.Add(boundColumn);
boundColumn.DataField = "DATA";
}
protected void RadGrid2_SortCommand(object sender, GridSortCommandEventArgs e)
{
}
private XmlNode getData(string userName, string gadgetID, string UWI)
{
XmlNode nodeUserData;
ewellDA objewellDA = new ewellDA();
nodeUserData = objewellDA.getData(userName, gadgetID, UWI);
return nodeUserData;
}
protected void RadGrid2_PreRender(object sender, EventArgs e)
{
foreach (GridGroupByExpression exp in RadGrid2.MasterTableView.GroupByExpressions)
{
exp.SelectFields.FindByName("DT_NAME").HeaderValueSeparator = string.Empty ;
}
// RadGrid2.Rebind();
}
protected void RadGrid2_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
if (!e.IsFromDetailTable)
{
RadGrid2.BorderStyle = BorderStyle.None;
RadGrid2.DataSource = GetDataTable(dtUserData, "DT");
}
}
protected void RadGrid2_DetailTableDataBind(object source, Telerik.WebControls.GridDetailTableDataBindEventArgs e)
{
GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
e.DetailTableView.BorderStyle = BorderStyle.None;
switch (e.DetailTableView.Name)
{
case "tableViewDS":
{
e.DetailTableView.ParentTableRelation[0].DetailKeyField = "DT_NAME";
e.DetailTableView.ParentTableRelation[0].MasterKeyField = "DT_NAME";
e.DetailTableView.ParentTableRelation[1].DetailKeyField = "DS_NAME";
e.DetailTableView.ParentTableRelation[1].MasterKeyField = "DS_NAME";
e.DetailTableView.DataSource = GetDataTable(dtUserData, "DS");
break;
}
case "tableViewINS":
{
e.DetailTableView.ParentTableRelation[0].DetailKeyField = "DT_NAME";
e.DetailTableView.ParentTableRelation[0].MasterKeyField = "DT_NAME";
e.DetailTableView.ParentTableRelation[1].DetailKeyField = "DS_NAME";
e.DetailTableView.ParentTableRelation[1].MasterKeyField = "DS_NAME";
e.DetailTableView.ParentTableRelation[2].DetailKeyField = "INS_NAME";
e.DetailTableView.ParentTableRelation[2].MasterKeyField = "INS_NAME";
e.DetailTableView.DataSource = GetDataTable(dtUserData, "INS");
break;
}
case "tableViewPRJ":
{
e.DetailTableView.ParentTableRelation[0].DetailKeyField = "DT_NAME";
e.DetailTableView.ParentTableRelation[0].MasterKeyField = "DT_NAME";
e.DetailTableView.ParentTableRelation[1].DetailKeyField = "DS_NAME";
e.DetailTableView.ParentTableRelation[1].MasterKeyField = "DS_NAME";
e.DetailTableView.ParentTableRelation[2].DetailKeyField = "INS_NAME";
e.DetailTableView.ParentTableRelation[2].MasterKeyField = "INS_NAME";
e.DetailTableView.ParentTableRelation[3].DetailKeyField = "PRJ_NAME";
e.DetailTableView.ParentTableRelation[3].MasterKeyField = "PRJ_NAME";
e.DetailTableView.DataSource = GetDataTable(dtUserData, "PRJ");
break;
}
}
}
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
{
string DT_NAME;
string DS_NAME;
string INS_NAME;
string PRJ_NAME;
string DATA;
string dataXml="";
// bool dataFound = false;
ArrayList compareText = new ArrayList();
if (e.Item is GridHeaderItem)
{
e.Item.BorderStyle = BorderStyle.None;
e.Item.BackColor = System.Drawing.Color.White;
//e.Item.BorderColor = System.Drawing.Color.BlanchedAlmond;
}
if (e.Item is GridGroupHeaderItem) // hyperlinks for DataType groups
// click and see report for all
// data stores under that DataType
{
e.Item.Expanded = false;
GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item;
string[] groupText = new string[2];
if (item.DataCell.Text.ToString().Contains(":"))
groupText = item.DataCell.Text.ToString().Split(':');
else
{
return;
}
//XmlNodeUserSelectedData
// query dtUserData for DATA item for the current DT_NAME
// make an xml string these DATA items
compareText.Add(groupText[1].Trim());
dataXml = gridDataHierarchyWise("DT", compareText );
if (dataXml != "" && dataXml != null)
{
Session["DATA_DT"] = "<OSP>" + dataXml + "</OSP>";
// dataXml = "<OSPDataStoreDetails>" + dataXml + "</OSPDataStoreDetails>";
item.DataCell.Text = "<a href='Default3.aspx?level=DT' target='_blank'>" + groupText[1] + " </a>";
item.DataCell.ToolTip = "click to view data from all selected Data Stores.";
}
else
{
item.DataCell.Text = groupText[1];
item.DataCell.ToolTip = "No Data Available";
}
}
if (e.Item is GridDataItem)
{
if (e.Item.OwnerTableView.Name.ToString() == "tableViewDT") // for DataStore Node
{
//get data for current Data Store and Data Type combination
DT_NAME = ((DataTable)(e.Item.OwnerTableView.DataSource)).Rows[RowCountDT]["DT_NAME"].ToString();
DS_NAME = ((DataTable)(e.Item.OwnerTableView.DataSource)).Rows[RowCountDT]["DS_NAME"].ToString();
//DT_NAME = e.Item.OwnerTableView.DataKeyValues[0]["DT_NAME"].ToString();
//DS_NAME = e.Item.OwnerTableView.DataKeyValues[0]["DS_NAME"].ToString();
RowCountDT++;
compareText.Add(DT_NAME.Trim());
compareText.Add(DS_NAME.Trim());
dataXml = gridDataHierarchyWise("DS", compareText);
if (dataXml != "" && dataXml != null)
{
// dataXml = "<OSPDataStoreDetails>" + dataXml + "</OSPDataStoreDetails>";
Session["DATA_DS"] = "<OSP>" + dataXml + "</OSP>";
GridDataItem item1 = (GridDataItem)e.Item;
item1["DS_NAME"].Text = "<a href='Default3.aspx?level=DS' target='_blank'>" + DS_NAME + " </a>";
item1.ToolTip = "click to view data from all selected Installations.";
}
else
{
GridDataItem item1 = (GridDataItem)e.Item;
item1["DS_NAME"].Text = DS_NAME ;
e.Item.ToolTip = "No Data Available";
}
}
else if (e.Item.OwnerTableView.Name.ToString() == "tableViewDS") // for Installation Node
{
//get data for current Data Store and Data Type combination
DT_NAME = e.Item.OwnerTableView.DataKeyValues[0]["DT_NAME"].ToString();
DS_NAME = e.Item.OwnerTableView.DataKeyValues[0]["DS_NAME"].ToString();
INS_NAME = e.Item.OwnerTableView.DataKeyValues[0]["INS_NAME"].ToString();
//DT_NAME = ((DataTable)(e.Item.OwnerTableView.DataSource)).Rows[RowCountDS]["DT_NAME"].ToString();
//DS_NAME = ((DataTable)(e.Item.OwnerTableView.DataSource)).Rows[RowCountDS]["DS_NAME"].ToString();
//INS_NAME = ((DataTable)(e.Item.OwnerTableView.DataSource)).Rows[RowCountDS]["INS_NAME"].ToString();
RowCountDS++;
compareText.Add(DT_NAME.Trim());
compareText.Add(DS_NAME.Trim());
compareText.Add(INS_NAME.Trim());
dataXml = gridDataHierarchyWise("INS", compareText);
if (dataXml != "" && dataXml != null)
{
//dataXml = "<OSPDataStoreDetails>" + dataXml + "</OSPDataStoreDetails>";
Session["DATA_INS"] = "<OSP>" + dataXml + "</OSP>";
GridDataItem item1 = (GridDataItem)e.Item;
item1["INS_NAME"].Text = "<a href='Default3.aspx?level=INS' target='_blank'>" + INS_NAME + " </a>";
item1.ToolTip = "click to view data from all selected Projects.";
}
else
{
e.Item.ToolTip = "No Data Available";
}
}
else if (e.Item.OwnerTableView.Name.ToString() == "tableViewINS") // for Installation Node
{
//get data for current Data Store and Data Type combination
DT_NAME = e.Item.OwnerTableView.DataKeyValues[RowCountINS]["DT_NAME"].ToString();
DS_NAME = e.Item.OwnerTableView.DataKeyValues[RowCountINS]["DS_NAME"].ToString();
INS_NAME = e.Item.OwnerTableView.DataKeyValues[RowCountINS]["INS_NAME"].ToString();
PRJ_NAME = e.Item.OwnerTableView.DataKeyValues[RowCountINS]["PRJ_NAME"].ToString();
/* DT_NAME = ((DataTable)(e.Item.OwnerTableView.DataSource)).Rows[RowCountINS]["DT_NAME"].ToString();
DS_NAME = ((DataTable)(e.Item.OwnerTableView.DataSource)).Rows[RowCountINS]["DS_NAME"].ToString();
INS_NAME = ((DataTable)(e.Item.OwnerTableView.DataSource)).Rows[RowCountINS]["INS_NAME"].ToString();
PRJ_NAME = ((DataTable)(e.Item.OwnerTableView.DataSource)).Rows[RowCountINS]["PRJ_NAME"].ToString();
*/
RowCountINS++;
compareText.Add(DT_NAME.Trim());
compareText.Add(DS_NAME.Trim());
compareText.Add(INS_NAME.Trim());
compareText.Add(PRJ_NAME.Trim());
dataXml = gridDataHierarchyWise("PRJ", compareText);
if (dataXml != "" && dataXml != null)
{
//dataXml = "<OSPDataStoreDetails>" + dataXml + "</OSPDataStoreDetails>";
Session["DATA_PRJ"] = "<OSP>" + dataXml + "</OSP>";
GridDataItem item1 = (GridDataItem)e.Item;
item1["PRJ_NAME"].Text = "<a href='Default3.aspx?level=PRJ' target='_blank'>" + PRJ_NAME + " </a>";
item1.ToolTip = "click to view data for this project.";
}
else
{
e.Item.ToolTip = "No Data Available";
}
}
else if (e.Item.OwnerTableView.Name.ToString() == "tableViewPRJ")
{
DT_NAME = e.Item.OwnerTableView.DataKeyValues[0]["DT_NAME"].ToString();
DS_NAME = e.Item.OwnerTableView.DataKeyValues[0]["DS_NAME"].ToString();
INS_NAME = e.Item.OwnerTableView.DataKeyValues[0]["INS_NAME"].ToString();
PRJ_NAME = e.Item.OwnerTableView.DataKeyValues[0]["PRJ_NAME"].ToString();
DATA = e.Item.OwnerTableView.DataKeyValues[0]["DATA"].ToString(); // hyperlink column data
XmlDocument myXmlDoc = new XmlDocument();
myXmlDoc.LoadXml(DATA);
string errorCode;
int dataRowCount = 0;
GridDataItem item1 = (GridDataItem)e.Item;
if (DATA.Substring(1, 9).ToUpper() == "EXCEPTION")
{
errorCode = (myXmlDoc.SelectSingleNode("/Exception/Code")).InnerText.ToString(); ;
item1["DATA"].Text = "Error Occured (Eror Code: " + errorCode + ")";
}
else
{
XmlNode DVNode = myXmlDoc.SelectSingleNode("/Data/DataValue");
if (DVNode.HasChildNodes)
{
dataRowCount = DVNode.ChildNodes.Count;
Session["DATA_DATA"] = "<OSP><OSPDataStoreDetails><OSPDataStore type='" + DS_NAME + "'><OSPDataStoreInstallation name='" + INS_NAME + "'><OSPProject name='" + PRJ_NAME + "'><OSPDataType name='" + DT_NAME + "'>" + DATA + "</OSPDataType></OSPProject> </OSPDataStoreInstallation></OSPDataStore></OSPDataStoreDetails></OSP>";
item1["DATA"].Text = "<a href='Default3.aspx?level=DATA' target='_blank'>" + dataRowCount + " record(s) available</a>";
}
else
{
item1["DATA"].Text = "Data not availabe";
}
}
}
}
else
{
}
}
private string gridDataHierarchyWise(string level, ArrayList compareText)
{
string dataXml="";
bool dataFound = false;
XmlNode NodesDS = XmlNodeUserSelectedData.ChildNodes[0].ChildNodes[0]; // points to all OSPDataStore nodes
foreach (XmlNode NodeDS in NodesDS) // points to all OSPDataStore nodes
{
//XmlNode NodeINS = NodeDS.ChildNodes[0]; // points to OSPDataStoreInstallation node under OSPDataStore node
// XmlNode NodePRJ = NodeDS.ChildNodes[0].ChildNodes[0]; // points to OSPProject node under OSPDataStore node
//XmlNode NodeDT = NodeDS.ChildNodes[0].ChildNodes[0].ChildNodes[0]; // points to OSPDataType node under OSPDataStore node
//XmlNode NodeINS ;
//XmlNode NodePRJ;
//XmlNode NodeDT;
switch (level)
{
case ("DT"):
{
string DT_NAME = (string)compareText[0];
//check the value of OSP DataType node for current OSPDataStore
foreach (XmlNode NodeINS in NodeDS)
{
foreach (XmlNode NodePRJ in NodeINS)
{
foreach (XmlNode NodeDT in NodePRJ)
{
if (NodeDT.Attributes["name"].Value.ToString().Trim() == DT_NAME)
{
//now check if this datastore has data by checking if DataValue node has childnodes or not
XmlNode tempNode = NodeDT.ChildNodes[0];
//return only when there is atleast one datastore with values
//if there's atleast one datastore with values, then others would display the
// error message. If all are erroneous then don't send back any data and simply return no data available
if (tempNode.Name.ToString() == "Data")// check if its an Exception or Data
{
XmlNode NodeDataValue = NodeDT.ChildNodes[0].ChildNodes[1];
if (NodeDataValue.HasChildNodes) //check if data available or not (i.e. Row node(s) present under DataValue node
{
//include this DataStore Outer xml in the final report string
// that needs to be passed on to the report page
dataFound = true;
}
}
//the following line needs to be revised
//this inludes all the datatypes under that Datastore
//which is wrong
// dataXml = dataXml + NodeDS.;
dataXml = dataXml + "<OSPDataStoreDetails><OSPDataStore ";
for (int i = 0; i < NodeDS.Attributes.Count; i++)
{
dataXml = dataXml + NodeDS.Attributes[i].Name.ToString() + "='" + NodeDS.Attributes[i].Value.ToString() + "' " ;
}
dataXml = dataXml + "><OSPDataStoreInstallation ";
for (int i = 0; i < NodeINS.Attributes.Count; i++)
{
dataXml = dataXml + NodeINS.Attributes[i].Name.ToString() + "='" + NodeINS.Attributes[i].Value.ToString() + "' ";
}
dataXml = dataXml + "><OSPProject ";
for (int i = 0; i < NodePRJ.Attributes.Count; i++)
{
dataXml = dataXml + NodePRJ.Attributes[i].Name.ToString() + "='" + NodePRJ.Attributes[i].Value.ToString() + "' ";
}
dataXml = dataXml + ">";
dataXml = dataXml + NodeDT.OuterXml.ToString();
dataXml = dataXml + "</OSPProject></OSPDataStoreInstallation></OSPDataStore></OSPDataStoreDetails>";
}
}
}
}
break;
}
case ("DS"):
{
string DT_NAME = (string)compareText[0];
string DS_NAME = (string)compareText[1];
//check the value of OSP DataType node for current OSPDataStore
foreach (XmlNode NodeINS in NodeDS)
{
foreach (XmlNode NodePRJ in NodeINS)
{
foreach (XmlNode NodeDT in NodePRJ)
{
if (NodeDS.Attributes["type"].Value.ToString().Trim() == DS_NAME && NodeDT.Attributes["name"].Value.ToString().Trim() == DT_NAME)
{
//now check if this datastore has data by checking if DataValue node has childnodes or not
XmlNode tempNode = NodeDT.ChildNodes[0];
if (tempNode.Name.ToString() == "Data") // check if its an Exception or Data
{
XmlNode NodeDataValue = NodeDT.ChildNodes[0].ChildNodes[1];
if (NodeDataValue.HasChildNodes) //check if data available or not (i.e. Row node(s) present under DataValue node
{
//include this DataStore Outer xml in the final report string
// that needs to be passed on to the report page
dataFound=true;
}
}
dataXml = dataXml + "<OSPDataStoreDetails><OSPDataStore ";
for (int i = 0; i < NodeDS.Attributes.Count; i++)
{
dataXml = dataXml + NodeDS.Attributes[i].Name.ToString() + "='" + NodeDS.Attributes[i].Value.ToString() + "' ";
}
dataXml = dataXml + "><OSPDataStoreInstallation ";
for (int i = 0; i < NodeINS.Attributes.Count; i++)
{
dataXml = dataXml + NodeINS.Attributes[i].Name.ToString() + "='" + NodeINS.Attributes[i].Value.ToString() + "' ";
}
dataXml = dataXml + "><OSPProject ";
for (int i = 0; i < NodePRJ.Attributes.Count; i++)
{
dataXml = dataXml + NodePRJ.Attributes[i].Name.ToString() + "='" + NodePRJ.Attributes[i].Value.ToString() + "' ";
}
dataXml = dataXml + ">";
dataXml = dataXml + NodeDT.OuterXml.ToString();
dataXml = dataXml + "</OSPProject></OSPDataStoreInstallation></OSPDataStore></OSPDataStoreDetails>";
}
}
}
}
break;
}
case ("INS"):
{
string DT_NAME = (string)compareText[0];
string DS_NAME = (string)compareText[1];
string INS_NAME = (string)compareText[2];
//check the value of OSP DataType node for current OSPDataStore
foreach (XmlNode NodeINS in NodeDS)
{
foreach (XmlNode NodePRJ in NodeINS)
{
foreach (XmlNode NodeDT in NodePRJ)
{
if (NodeDS.Attributes["type"].Value.ToString().Trim() == DS_NAME && NodeDT.Attributes["name"].Value.ToString().Trim() == DT_NAME && NodeINS.Attributes["name"].Value.ToString().Trim() == INS_NAME)
{
//now check if this datastore has data by checking if DataValue node has childnodes or not
XmlNode tempNode = NodeDT.ChildNodes[0];
if (tempNode.Name.ToString() == "Data") // check if its an Exception or Data
{
XmlNode NodeDataValue = NodeDT.ChildNodes[0].ChildNodes[1];
if (NodeDataValue.HasChildNodes) //check if data available or not (i.e. Row node(s) present under DataValue node
{
//include this DataStore Outer xml in the final report string
// that needs to be passed on to the report page
dataFound = true;
}
}
dataXml = dataXml + "<OSPDataStoreDetails><OSPDataStore ";
for (int i = 0; i < NodeDS.Attributes.Count; i++)
{
dataXml = dataXml + NodeDS.Attributes[i].Name.ToString() + "='" + NodeDS.Attributes[i].Value.ToString() + "' ";
}
dataXml = dataXml + "><OSPDataStoreInstallation ";
for (int i = 0; i < NodeINS.Attributes.Count; i++)
{
dataXml = dataXml + NodeINS.Attributes[i].Name.ToString() + "='" + NodeINS.Attributes[i].Value.ToString() + "' ";
}
dataXml = dataXml + "><OSPProject ";
for (int i = 0; i < NodePRJ.Attributes.Count; i++)
{
dataXml = dataXml + NodePRJ.Attributes[i].Name.ToString() + "='" + NodePRJ.Attributes[i].Value.ToString() + "' ";
}
dataXml = dataXml + ">";
dataXml = dataXml + NodeDT.OuterXml.ToString();
dataXml = dataXml + "</OSPProject></OSPDataStoreInstallation></OSPDataStore></OSPDataStoreDetails>";
}
}
}
}
break;
}
case ("PRJ"):
{
string DT_NAME = (string)compareText[0];
string DS_NAME = (string)compareText[1];
string INS_NAME = (string)compareText[2];
string PRJ_NAME = (string)compareText[3];
//check the value of OSP DataType node for current OSPDataStore
foreach (XmlNode NodeINS in NodeDS)
{
foreach (XmlNode NodePRJ in NodeINS)
{
foreach (XmlNode NodeDT in NodePRJ)
{
if (NodeDS.Attributes["type"].Value.ToString().Trim() == DS_NAME && NodeDT.Attributes["name"].Value.ToString().Trim() == DT_NAME && NodeINS.Attributes["name"].Value.ToString().Trim() == INS_NAME && NodePRJ.Attributes["name"].Value.ToString().Trim() == PRJ_NAME)
{
//now check if this datastore has data by checking if DataValue node has childnodes or not
XmlNode tempNode = NodeDT.ChildNodes[0];
if (tempNode.Name.ToString() == "Data") // check if its an Exception or Data
{
XmlNode NodeDataValue = NodeDT.ChildNodes[0].ChildNodes[1];
if (NodeDataValue.HasChildNodes) //check if data available or not (i.e. Row node(s) present under DataValue node
{
//include this DataStore Outer xml in the final report string
// that needs to be passed on to the report page
dataFound = true;
}
}
dataXml = dataXml + "<OSPDataStoreDetails><OSPDataStore ";
for (int i = 0; i < NodeDS.Attributes.Count; i++)
{
dataXml = dataXml + NodeDS.Attributes[i].Name.ToString() + "='" + NodeDS.Attributes[i].Value.ToString() + "' ";
}
dataXml = dataXml + "><OSPDataStoreInstallation ";
for (int i = 0; i < NodeINS.Attributes.Count; i++)
{
dataXml = dataXml + NodeINS.Attributes[i].Name.ToString() + "='" + NodeINS.Attributes[i].Value.ToString() + "' ";
}
dataXml = dataXml + "><OSPProject ";
for (int i = 0; i < NodePRJ.Attributes.Count; i++)
{
dataXml = dataXml + NodePRJ.Attributes[i].Name.ToString() + "='" + NodePRJ.Attributes[i].Value.ToString() + "' ";
}
dataXml = dataXml + ">";
dataXml = dataXml + NodeDT.OuterXml.ToString();
dataXml = dataXml + "</OSPProject></OSPDataStoreInstallation></OSPDataStore></OSPDataStoreDetails>";
}
}
}
}
break;
}
}
}
if (dataFound==false)
dataXml="";
return dataXml;
}
public DataTable GetDataTable(DataTable dtUserData, string level)
{
dtUserData.DefaultView.Sort = "DT_NAME, DS_NAME, INS_NAME, PRJ_NAME, DATA";
string old_DS = "";
string new_DS = "";
string old_DT = "";
string new_DT = "";
string old_INS = "";
string new_INS = "";
string old_PRJ = "";
string new_PRJ = "";
//string new_DATA = "";
DataTable myTable = new DataTable("tempDT");
DataColumn DT_NAME_Column;
DataColumn DS_NAME_Column;
DataColumn INS_NAME_Column;
DataColumn PRJ_NAME_Column;
DataColumn DATA_Column;
DataRow myRow;
DT_NAME_Column = new DataColumn();
DT_NAME_Column.DataType = System.Type.GetType("System.String");
DT_NAME_Column.ColumnName = "DT_NAME";
DT_NAME_Column.DefaultValue = "DT_NAME";
myTable.Columns.Add(DT_NAME_Column);
DS_NAME_Column = new DataColumn();
DS_NAME_Column.DataType = System.Type.GetType("System.String");
DS_NAME_Column.ColumnName = "DS_NAME";
DS_NAME_Column.DefaultValue = "DS_NAME";
myTable.Columns.Add(DS_NAME_Column);
INS_NAME_Column = new DataColumn();
INS_NAME_Column.DataType = System.Type.GetType("System.String");
INS_NAME_Column.ColumnName = "INS_NAME";
INS_NAME_Column.DefaultValue = "INS_NAME";
myTable.Columns.Add(INS_NAME_Column);
PRJ_NAME_Column = new DataColumn();
PRJ_NAME_Column.DataType = System.Type.GetType("System.String");
PRJ_NAME_Column.ColumnName = "PRJ_NAME";
PRJ_NAME_Column.DefaultValue = "PRJ_NAME";
myTable.Columns.Add(PRJ_NAME_Column);
DATA_Column = new DataColumn();
DATA_Column.DataType = System.Type.GetType("System.String");
DATA_Column.ColumnName = "DATA";
DATA_Column.DefaultValue = "DATA";
myTable.Columns.Add(DATA_Column);
if (level == "DT")
{
for (int i = 0; i < dtUserData.DefaultView.Count; i++)
{
new_DT = dtUserData.DefaultView[i]["DT_NAME"].ToString();
new_DS = dtUserData.DefaultView[i]["DS_NAME"].ToString();
// new_INS = dtUserData.DefaultView[i]["INS_NAME"].ToString();
//new_PRJ = dtUserData.DefaultView[i]["PRJ_NAME"].ToString();
// new_DATA = dtUserData.DefaultView[i]["DATA"].ToString();
if ((new_DT == old_DT) && (new_DS == old_DS))
{
}
else
{
myRow = myTable.NewRow();
myRow["DT_NAME"] = new_DT;
myRow["DS_NAME"] = new_DS;
// myRow["INS_NAME"] = new_INS;
// myRow["PRJ_NAME"] = new_PRJ;
// myRow["DATA"] = new_DATA;
myTable.Rows.Add(myRow);
old_DT = new_DT;
old_DS = new_DS;
}
}
}
else if (level == "DS")
{
for (int i = 0; i < dtUserData.DefaultView.Count; i++)
{
new_DT = dtUserData.DefaultView[i]["DT_NAME"].ToString();
new_DS = dtUserData.DefaultView[i]["DS_NAME"].ToString();
new_INS = dtUserData.DefaultView[i]["INS_NAME"].ToString();
// new_PRJ = dtUserData.DefaultView[i]["PRJ_NAME"].ToString();
// new_DATA = dtUserData.DefaultView[i]["DATA"].ToString();
if ((new_DT == old_DT) && (new_DS == old_DS) && (new_INS == old_INS))
{
}
else
{
myRow = myTable.NewRow();
myRow["DT_NAME"] = new_DT;
myRow["DS_NAME"] = new_DS;
myRow["INS_NAME"] = new_INS;
// myRow["PRJ_NAME"] = new_PRJ;
// myRow["DATA"] = new_DATA;
myTable.Rows.Add(myRow);
old_DT = new_DT;
old_DS = new_DS;
old_INS = new_INS;
}
}
}
else if (level == "INS")
{
for (int i = 0; i < dtUserData.DefaultView.Count; i++)
{
new_DT = dtUserData.DefaultView[i]["DT_NAME"].ToString();
new_DS = dtUserData.DefaultView[i]["DS_NAME"].ToString();
new_INS = dtUserData.DefaultView[i]["INS_NAME"].ToString();
new_PRJ = dtUserData.DefaultView[i]["PRJ_NAME"].ToString();
// new_DATA = dtUserData.DefaultView[i]["DATA"].ToString();
if ((new_DT == old_DT) && (new_DS == old_DS) && (new_INS == old_INS) && (new_PRJ == old_PRJ))
{
}
else
{
myRow = myTable.NewRow();
myRow["DT_NAME"] = new_DT;
myRow["DS_NAME"] = new_DS;
myRow["INS_NAME"] = new_INS;
myRow["PRJ_NAME"] = new_PRJ;
// myRow["DATA"] = new_DATA;
myTable.Rows.Add(myRow);
old_DT = new_DT;
old_DS = new_DS;
old_INS = new_INS;
old_PRJ = new_PRJ;
}
}
}
else if (level == "PRJ")
{
myTable = dtUserData ;
}
return myTable;
}
}
------------------------------------------
-------------------------------------------------
Again, this is a hierarchical grid for 4 level hierarchy
and it doesn't do anything after hierarchy level 2 because i loses track or viewstate for relations beween master-child tableviews from level 3 onwards.
If i keep submitting the page back to the server on every postback and keeping all the relations defined in the code for DetailTableBind function, it works fine.
However, paging and sorting doesn't work at all.
If i don't submit to the server on post back and take the shield on Ajax it doesn't work even if i put the relations in DetailTableViewBind function.
I have only 2 days left to submit my proposal and I think I've almost lost it.
Can you guys be of any help. buying a license depends on complete working of this piece
Thanks
0
Hello Hary,
Excuse me for the late answer. I spend a lot of time, investigating the issue you mentioned. I mean the following:
"1. View state doesn't get copied at some levels"
I tried to reproduce the issue on my own several times and I realized that there is no problem with the hierarchy.
So, for your convenience I've prepared examples with 5-level hierarchy illustrating programmatic creation both on Load and Init events.
Regarding the support tickets: please find the attached zip file with screenshots describing the way to submit support ticket. If you are still stuck please describe the exact steps you followed and the error (if any) which is thrown.
Let me know whether the directions are helpful.
Kind regards,
Daniel
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Excuse me for the late answer. I spend a lot of time, investigating the issue you mentioned. I mean the following:
"1. View state doesn't get copied at some levels"
I tried to reproduce the issue on my own several times and I realized that there is no problem with the hierarchy.
So, for your convenience I've prepared examples with 5-level hierarchy illustrating programmatic creation both on Load and Init events.
Regarding the support tickets: please find the attached zip file with screenshots describing the way to submit support ticket. If you are still stuck please describe the exact steps you followed and the error (if any) which is thrown.
Let me know whether the directions are helpful.
Kind regards,
Daniel
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

Hary
Top achievements
Rank 1
answered on 22 Jul 2008, 01:11 PM
Hi Daniel,
You have tried a very basic case and that would work. Please try to replicate it my way. If you look in to the code that I sent in GenerateGrid() method, I have a group in the first level. Also I am changing all the databoundcolumns to hyperlinks i.e <a>text</a> in ItemDataBound event's function based on certain conditions.
I would appreciate it if you replicate it exactly the same way I am trying it.
Thanks,
You have tried a very basic case and that would work. Please try to replicate it my way. If you look in to the code that I sent in GenerateGrid() method, I have a group in the first level. Also I am changing all the databoundcolumns to hyperlinks i.e <a>text</a> in ItemDataBound event's function based on certain conditions.
I would appreciate it if you replicate it exactly the same way I am trying it.
Thanks,
0
Hello Hary/Jas,
As you can see on attached example RadGrid uses NeedDataSource, sorting and grouping. Also I put initial grouping as you do and I also put some code into GridGroupHeaderItems and GridDataItems. This is still at the five levels and all done in code-behind. (I suppose you don't expect me to recreate your XML data source.)
From this point, please let me know how to reproduce the issues you mentioned before:
1. View state doesn't get copied at some levels.
2. Duplication of child rows and columns on sort and page command.
Regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
As you can see on attached example RadGrid uses NeedDataSource, sorting and grouping. Also I put initial grouping as you do and I also put some code into GridGroupHeaderItems and GridDataItems. This is still at the five levels and all done in code-behind. (I suppose you don't expect me to recreate your XML data source.)
From this point, please let me know how to reproduce the issues you mentioned before:
1. View state doesn't get copied at some levels.
2. Duplication of child rows and columns on sort and page command.
Regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

Hary
Top achievements
Rank 1
answered on 24 Jul 2008, 06:11 PM
Hello Daniel,
I appreciate your time and effort. Do you see anything wrong the way I've written my code. Just for the demo purpose, I am not using the sorting and paging functionality for the reasons already mentioned. I'll have to look out for a way by which you can reproduce the same problem that i am facing at your end. I don't think so you'll be able to help me out without that and I do understand your point. However, I was wondering if you could have a look at the code that I sent you and see if you think there's some culprit code there that might mess up with viewstate(which is not an issue as of now cuz am reloading the whole grid every single time, a bad work around), paging and sorting.
Thanks,
Hary
I appreciate your time and effort. Do you see anything wrong the way I've written my code. Just for the demo purpose, I am not using the sorting and paging functionality for the reasons already mentioned. I'll have to look out for a way by which you can reproduce the same problem that i am facing at your end. I don't think so you'll be able to help me out without that and I do understand your point. However, I was wondering if you could have a look at the code that I sent you and see if you think there's some culprit code there that might mess up with viewstate(which is not an issue as of now cuz am reloading the whole grid every single time, a bad work around), paging and sorting.
Thanks,
Hary
0
Hi Hary,
You create your RadGrid no matter if it is PostBack or not. This is why your columns are duplicated. This is in direct conflict with the conventions for programmatic grid creation outlined here. Also I suspect that this.PlaceHolder1.Controls.Clear(); can cause your problems with the viewstate.
I would like to kindly ask you if you have further questions and problems to isolate the problem into a simplified working example. This will help you get faster reply and also utilize our effort in providing the most accurate answer for your case.
Regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
You create your RadGrid no matter if it is PostBack or not. This is why your columns are duplicated. This is in direct conflict with the conventions for programmatic grid creation outlined here. Also I suspect that this.PlaceHolder1.Controls.Clear(); can cause your problems with the viewstate.
I would like to kindly ask you if you have further questions and problems to isolate the problem into a simplified working example. This will help you get faster reply and also utilize our effort in providing the most accurate answer for your case.
Regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

Hary
Top achievements
Rank 1
answered on 31 Jul 2008, 12:00 AM
Hi,
I could solve that problem related to my hierarchical grid.
Everything seems working fine on pageLoad.
Now I have a question.
How can I show a default loading image when my hierarchical grid is still getting loaded ?
Is this handle in some special way in hierarchichal grid.
Please let me know
Thanks
I could solve that problem related to my hierarchical grid.
Everything seems working fine on pageLoad.
Now I have a question.
How can I show a default loading image when my hierarchical grid is still getting loaded ?
Is this handle in some special way in hierarchichal grid.
Please let me know
Thanks
0
Hi Hary,
In order to display loading image when loading nested levels in hierarchical grid (using HierarchyLoadMode = ServerOnDemand or ServerBind), ajaxify the grid with RadAjaxManager or RadAjaxPanel and relate RadAjaxLoadingPanel with it:
http://www.telerik.com/DEMOS/ASPNET/Prometheus/Ajax/Examples/Overview/DefaultCS.aspx
If you would like to display loading indicator on initial load as well (before the grid hierarchy is fully loaded), consider the approach presented in this section of the RadAjax documentation:
http://www.telerik.com/help/aspnet-ajax/ajxshowloadingpaneloninitialpageload.html
Regards,
Stephen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
In order to display loading image when loading nested levels in hierarchical grid (using HierarchyLoadMode = ServerOnDemand or ServerBind), ajaxify the grid with RadAjaxManager or RadAjaxPanel and relate RadAjaxLoadingPanel with it:
http://www.telerik.com/DEMOS/ASPNET/Prometheus/Ajax/Examples/Overview/DefaultCS.aspx
If you would like to display loading indicator on initial load as well (before the grid hierarchy is fully loaded), consider the approach presented in this section of the RadAjax documentation:
http://www.telerik.com/help/aspnet-ajax/ajxshowloadingpaneloninitialpageload.html
Regards,
Stephen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

Hary
Top achievements
Rank 1
answered on 31 Jul 2008, 09:06 PM
Hello Stephen,
In the same hierarchical grid I am facing problems with paging in mastertableview
I have no paging for any of the detail table views.
RadGrid2.MasterTableView.PageSize = 5;
However, if mastertable view has 7 records lets say, it displays only 4 in page1 and small grey strip right at the bottom that has various links for paging shows "Items 1 to 5 of 10"
This is something that doesn't match with what I have in my grid or page. This behavior is very erratic. How can I fix this ?
Please let me know what is the right way to do this.
Thanks
In the same hierarchical grid I am facing problems with paging in mastertableview
I have no paging for any of the detail table views.
RadGrid2.MasterTableView.PageSize = 5;
However, if mastertable view has 7 records lets say, it displays only 4 in page1 and small grey strip right at the bottom that has various links for paging shows "Items 1 to 5 of 10"
This is something that doesn't match with what I have in my grid or page. This behavior is very erratic. How can I fix this ?
Please let me know what is the right way to do this.
Thanks
0
Hello Hary,
Can you please modify any of the examples attached previously in order to reproduce this behavior? Thus I will be able to advice you further.
Regards,
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Can you please modify any of the examples attached previously in order to reproduce this behavior? Thus I will be able to advice you further.
Regards,
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.