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

[Solved] Two Rows per Data Item in Rad Grid

2 Answers 332 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 20 Apr 2009, 02:33 PM

Hello,

I am trying to set up a rad grid to render two table rows for each data item. This is because of the way the data needs to be displayed, an approximation of which is below:

____________________________________________________

|____Field1_____|_______Field2______|_______Field3_______|

|____________Field4 (Long Text Field)_____________________|

So far, the only way I have found to do this is by using the "NestedViewTemplate" property of the MasterTableView. So my first question is, is there a better way of doing this, or is the "NestedViewTemplate" my only option?

Secondly, if the "NestedViewTemplate" is the only way to do it, then how do I remove the automatically generated column which has the button to expand the nested view template? I will be using "HierarchyDefaultExpanded" property of the MasterTableView to make sure the nested view is always displayed, but I don't want users to be able to hide it. Obviously, the buttons could be hidden using CSS, but that still leaves the column generated for them, and no specific CSS classes appear to be applied to it so I cannot use CSS to hide the column (also cannot use CSS selectors (i.e. GridRow>td:first-child) for reasons beyond the scope of this question).

Any help much appreciated,

Andrew

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Apr 2009, 04:12 AM
Hi Andrew.

Try the following line of code in the PreRender event of the Grid to hide the expand/collpase column.

CS:
 
 protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        RadGrid1.MasterTableView.GetColumn("ExpandColumn").Display = false
    } 


Thanks
Shinu
0
Andrew
Top achievements
Rank 1
answered on 21 Apr 2009, 08:19 AM

Hi Shinu,

Thanks for your response.

I've tried what you suggested - it appears to be adding a " style='display:none; " to the table cell containing the show/hide button. So, first problem is that if a user has CSS disabled for whatever reason, the button is still present. Setting the "Visible" property of the "ExpandColumn" to "False" doesn't appear to have any effect. Is there any way to completely remove the column from the rendered output?

(If not, it is worth noting that additional code is required to set the "display" css property to "none" on the first table cell in the nested view template, I'm doing this via a line of code ' CType(e.Item.Controls(0), GridTableCell).Style("display") = "none" ' in the ItemCreated event - is there a better way of doing that?)

Kind regards,

Andrew

Tags
Grid
Asked by
Andrew
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Andrew
Top achievements
Rank 1
Share this question
or