Erik Hinds
Top achievements
Rank 1
Erik Hinds
asked on 07 Oct 2009, 10:18 PM
I have a nested radgrid setup where the detail table column name is retrieved from one of the parent's hidden columns. I set this in the detail databind below. When I sort another child grid on any column, all the custom headers on the other grids revert back to default. The custom column in the sorting grid retains it's header text.
Is there another place I should set the header text so it will persist?
| Protected Sub radGridApplicantReport_DetailTableDataBind1(ByVal source As Object, ByVal e As Telerik.Web.UI.GridDetailTableDataBindEventArgs) Handles radGridApplicantReport.DetailTableDataBind |
| Dim dataItem As GridDataItem = CType(e.DetailTableView.ParentItem, GridDataItem) |
| If (e.DetailTableView.Name = "ApplicantList") Then |
| 'XfactorDisplay |
| If (dataItem.Item("XfactorDisplayFlag").Text = "False") Then |
| e.DetailTableView.Columns(11).Visible = False |
| Else |
| e.DetailTableView.Columns(11).Visible = True |
| 'If we are showing, change the header |
| If Not (dataItem.Item("XfactorDisplayText").Text = "") Then |
| e.DetailTableView.Columns(11).HeaderText = dataItem.Item("XfactorDisplayText").Text |
| End If |
| End If |
| If (dataItem.Item("ShowRatingFlag").Text = "False") Then |
| e.DetailTableView.Columns(12).Visible = False |
| Else |
| e.DetailTableView.Columns(12).Visible = True |
| End If |
| End If |
| End Sub |
Is there another place I should set the header text so it will persist?
12 Answers, 1 is accepted
0
Hi Erik,
To see more information along the lines of the requested functionality, please refer to the following article:
http://www.telerik.com/help/aspnet-ajax/grdtraversingdetailtablesitemsingrid.html
For each table, you can hide any column, or set the headertext.
I hope this gets you started properly.
Sincerely yours,
Yavor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
To see more information along the lines of the requested functionality, please refer to the following article:
http://www.telerik.com/help/aspnet-ajax/grdtraversingdetailtablesitemsingrid.html
For each table, you can hide any column, or set the headertext.
I hope this gets you started properly.
Sincerely yours,
Yavor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Erik Hinds
Top achievements
Rank 1
answered on 26 Oct 2009, 06:20 PM
Yes, I am doing what's in the article. The problem is maintaining those values while sorting another child grid. What am I doing incorrectly?
Thanks
Thanks
0
Hello Erik,
Since the text is reverted back to the original value, this means that the event is not raised on postback. Hence, you can move the logic in the PreRender event handler of the grid - there you can iterate through all the items and child items in the grid, and set the column/header text accordingly. You can also directly get a reference to the header item(s) and the column cells:
http://www.telerik.com/help/aspnet-ajax/grdaccessingcellsandrows.html
Since the PreRender event handler is raised on each page cycle, the information will be set as expected.
I hope this information helps.
All the best,
Yavor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Since the text is reverted back to the original value, this means that the event is not raised on postback. Hence, you can move the logic in the PreRender event handler of the grid - there you can iterate through all the items and child items in the grid, and set the column/header text accordingly. You can also directly get a reference to the header item(s) and the column cells:
http://www.telerik.com/help/aspnet-ajax/grdaccessingcellsandrows.html
Since the PreRender event handler is raised on each page cycle, the information will be set as expected.
I hope this information helps.
All the best,
Yavor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Erik Hinds
Top achievements
Rank 1
answered on 04 Nov 2009, 10:38 PM
Ok, got the prerender event gong, thanks for the tip!
The problem is that I can change everything BUT the header text
The header text becomes underlined but the text itself doesn't change. It is the same case whether It is a sortable header or not.
Not sure what else to do. Could this be a bug? Or am I accessing the header text property incorrectly?
The problem is that I can change everything BUT the header text
| Protected Sub radGridApplicantReport_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles radGridApplicantReport.PreRender |
| For Each item As GridDataItem In radGridApplicantReport.Items |
| If (item.OwnerTableView.Name = "ApplicantList") Then |
| If Not (item("XfactorDisplayText").Text = "") Then |
| item.OwnerTableView.Columns(11).HeaderStyle.Font.Underline = True |
| item.OwnerTableView.Columns(11).HeaderText = "asdfasdf" |
| End If |
| End If |
| Next |
| End Sub |
The header text becomes underlined but the text itself doesn't change. It is the same case whether It is a sortable header or not.
Not sure what else to do. Could this be a bug? Or am I accessing the header text property incorrectly?
0
Princy
Top achievements
Rank 2
answered on 05 Nov 2009, 12:06 PM
Hi Erik,
Check out the following code to change the header text:
vb:
Thanks
Princy.
Check out the following code to change the header text:
vb:
| Protected Sub radGridApplicantReport_PreRender(sender As Object, e As EventArgs) |
| For Each item As GridDataItem In radGridApplicantReport.Items |
| If (item.OwnerTableView.Name = "ApplicantList") Then |
| If Not (item("XfactorDisplayText").Text = "") Then |
| Dim header As GridHeaderItem = DirectCast(item.OwnerTableView.GetItems(GridItemType.Header)(0), GridHeaderItem) |
| header("XfactorDisplayText").Text = "asdfasdf" |
| header("XfactorDisplayText").Font.Underline = True |
| ' when sorting is enabled |
| (DirectCast(header("XfactorDisplayText").Controls(0), LinkButton)).Text = "asdfasdf" |
| (DirectCast(header("XfactorDisplayText").Controls(0), LinkButton)).Font.Underline = True |
| End If |
| End If |
| Next |
| End Sub |
Thanks
Princy.
0
Erik Hinds
Top achievements
Rank 1
answered on 05 Nov 2009, 02:36 PM
Thanks Princy! That's very close. It works except for casting the linkbutton. It cannot find the control
Specified argument was out of the range of valid values. Parameter name: index
Sorting is set to true. This is the problem:
I also tried getting it from the GridHeaderItem, but no luck.
Specified argument was out of the range of valid values. Parameter name: index
Sorting is set to true. This is the problem:
| DirectCast(item("XfactorDisplayText").Controls(0), LinkButton).Text = "whatever" |
I also tried getting it from the GridHeaderItem, but no luck.
0
Erik Hinds
Top achievements
Rank 1
answered on 09 Nov 2009, 09:36 PM
This must be a bug since I cannot get the link button text to change. I can change other properties, except the darn text
0
Hi Erik,
You can put a break point in the PreRender event handler, and verify that there are any controls in the cell.If there are none, you can symply alter the text of the header item cell:
item("XfactorDisplayText").Text="UpdatedText"
I hope this suggestion helps.
All the best,
Yavor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
You can put a break point in the PreRender event handler, and verify that there are any controls in the cell.If there are none, you can symply alter the text of the header item cell:
item("XfactorDisplayText").Text="UpdatedText"
I hope this suggestion helps.
All the best,
Yavor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Erik Hinds
Top achievements
Rank 1
answered on 10 Nov 2009, 08:51 PM
Thanks Yavor, but that doesn't help.
I get an error: Specified argument was out of the range of valid values. Parameter name: index
It cannot find the linkbutton control. Is it available in prerender??? Have I lost my mind? Is it because this is a child grid?
| Protected Sub radGridApplicantReport_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles radGridApplicantReport.PreRender |
| For Each item As GridDataItem In radGridApplicantReport.Items |
| If (item.OwnerTableView.Name = "ApplicantList") Then |
| If Not (item("XfactorDisplayText").Text = "") Then |
| Dim header As GridHeaderItem = DirectCast(item.OwnerTableView.GetItems(GridItemType.Header)(0), GridHeaderItem) |
| If Not header Is Nothing Then |
| header("XfactorDisplayText").Text = item("XfactorDisplayText").Text |
| DirectCast(header("XfactorDisplayText").Controls(0), LinkButton).Text = "Whatever" |
| End If |
| End If |
| End If |
| Next |
| End Sub |
I get an error: Specified argument was out of the range of valid values. Parameter name: index
It cannot find the linkbutton control. Is it available in prerender??? Have I lost my mind? Is it because this is a child grid?
0
Hello Erik,
At this point, in order to further track the issue, it will be best if you open a formal support ticket, and supply a small working project, demonstrating your setup, and showing the unwanted exception. We will review it locally, and get back to you with additional information.
Kind regards,
Yavor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
At this point, in order to further track the issue, it will be best if you open a formal support ticket, and supply a small working project, demonstrating your setup, and showing the unwanted exception. We will review it locally, and get back to you with additional information.
Kind regards,
Yavor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Erik Hinds
Top achievements
Rank 1
answered on 13 Nov 2009, 03:06 PM
This is a huge solution, and in DNN. Are you sure about that?
0
Hi Erik,
You can reduce the sample, by removing any unrelated/unnecessary controls, and send it for further inspection.
Regards,
Yavor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
You can reduce the sample, by removing any unrelated/unnecessary controls, and send it for further inspection.
Regards,
Yavor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.