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

access to inner gridview and redundant columns

1 Answer 98 Views
GridView
This is a migrated thread and some comments may be shown as answers.
shai
Top achievements
Rank 1
shai asked on 17 Nov 2010, 08:03 AM
Hello,
As a part of an application I'm developing, I'm writing a very basic XML viewer. It gets an xsd schema and an xml file, and should display the xml contents in gridview, so the user can expand each row to discover its inner properties.
I've tried using telerik's grid view for the mission, and I had three problems:
1. It adds 'redundant' columns to the grid - for example I have 'name' and 'address' properties, and it adds a column named 'name_id' which contains indices of the rows. I didn't understand why it does that and how can I disable that, so I tried hiding this extra column (which doesn't appear in the xsd schema), which leads me to my second problem:
2. I can access columns and rows of the 'main' grid, the one that contains the first level data, but how can I access the inner grids, the ones that open up when the user expands a row? I have an event handler for expanding rows, but I couldn't find a way to get the inner gridview from its arguments.
3. How can I change the font dynamically? I want the user to be able to resize the font. I tried using the font property of the gridview object, but it doesn't do anything(!). In this forum I saw people talking about doing it in the grid xml, for the specific table which font is to be determined, but I can't do it dynamically, I think.
Thank you,
Shai

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 22 Nov 2010, 09:35 AM
Hello shai,

Thank you for contacting us. Regarding your questions:

1. By default RadGridView reads all properties listed in the data source and generates columns for them. You can hide a column by setting its IsVisible property to false. Another option is to disable the automatic generation of columns by setting the AutoGenerateColumns property to false. In this case you should add all desired columns manually.

2. You can access the rows from specific child view by using the ChildRows property:

foreach (GridViewRowInfo row in this.radGridView1.Rows[5].ChildRows)
{
    //...
}

You can get the logical view, assigned with specific parent row converting the row object to GridViewHierarchyRowInfo:

GridViewHierarchyRowInfo hierarchyRow = (GridViewHierarchyRowInfo)this.radGridView1.Rows[5];
GridViewInfo childViewInfo = hierarchyRow.ChildRow.ChildViewInfo;

3. You can change the font by using the CellFormatting event. Please consider the GridView - Customize - Formatting with Code example from our demo application. The following help article contains further information.

I hope this helps.

All the best,

Jack
the Telerik team
Get started with RadControls for WinForms with numerous videos and detailed documentation.
Tags
GridView
Asked by
shai
Top achievements
Rank 1
Answers by
Jack
Telerik team
Share this question
or