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

[Solved] RadGrid DetailTable - hiding a column

2 Answers 349 Views
Grid
This is a migrated thread and some comments may be shown as answers.
franchute
Top achievements
Rank 1
franchute asked on 19 Feb 2008, 02:08 PM
Hi guys, I have the following situation.

I have a RadGrid control with two levels. Both levels are binded to two diferent ObjectDataSources.
The second Level (the DetailTable) expects ColumnA, ColumnB, and ColumnC.

However, the second objectdatasource (the one binded to the second level) will not always retrieve the three columns described above, instead, It would be returning ColumnA and ColumnC (not ColumnB) if  necessary. So, I'm asking whether the source is retrieving this column or not. If it's not, then I manually hide this column in my ODSDetailTable_Selected event by doing something like that:

RadGrid1.MasterTableView.DetailTables[0].Columns.FindByUniqueName("ColumnB").Visible = false;

However, this is not working fine. The first time I click de + icon to expand the second level, the column is appearing with the following value : System.Data.DataRowView

Then, I collapse the row and click again in the + icon and this time the row is hiding the column as I manually specified before.

I have proved this method in my DetailTableDataBind and the issue is appearing as well.

Do you have any clue about this ?

Thanks,

François.


2 Answers, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 20 Feb 2008, 11:26 AM
Hello  François,

There are some important details, related to hierarchical RadGrid, that I need to point out before going to the solution. While there is only one master table and setting its columns properties are applied directly, for detail tables there is one source and each detail table on the same level is copied from it. You can find more details here. When setting  RadGrid1.MasterTableView.DetailTables[0].Columns.FindByUniqueName("ColumnB").Visible = false; the source is modified, but the updates will be reflected after rebinding the grid, that is when the copies are created.

You will need to either use this expression before the grid is databound, so that all copies of this detail table are created with the corresponding column hidden, or loop through all detail tables and hide their columns. The latter could be done in PreRender event handler. This help topic provides more details about looping through all detail tables. You can limit this to the first level detail table only.

Hope this helps.

Greetings,
Ves
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
franchute
Top achievements
Rank 1
answered on 20 Feb 2008, 01:22 PM
Okay, thanks ... I will give it a try.


Tags
Grid
Asked by
franchute
Top achievements
Rank 1
Answers by
Ves
Telerik team
franchute
Top achievements
Rank 1
Share this question
or