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

Using ExtendedProperties and Column Grouping

1 Answer 374 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul Kavanagh
Top achievements
Rank 1
Paul Kavanagh asked on 04 Oct 2009, 01:41 PM
I have two related questions. The first is regarding datatable column extendedproperties. Is there a way to access these direction from the RadGrid object once the datasource bound, or do we have to iterate through both the datasource and the grid columns to do whatever we need to with the extended properties?

The second question is about the scenario related to the above question. I am looking for the most efficient approach. I want to create "column groups" so that I can set properties for groups of columns that are related based on business logic. Set visibility, item styles, etc. When I create the data source (data table) I am assigning extended properties using ExtendedProperties, i.e.,

column.ExtendedProperties.Add(

"ColumnGroup", "ImageTransform")
or

column.ExtendedProperties.Add(

"ColumnGroup", "Calcs")

I was thinking about getting the RadGrid object at Page.Prerender, then iterating through the data from the datasource, and then the columns collection to do whatever property assignments. But, I also figured that it might be more efficient to do if the ExtendedProperties were available directly.

 

1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 08 Oct 2009, 10:15 AM
Hello Paul,

If you are binding RadGird as follow:
protected void grid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
        DataTable dt = new DataTable();
        dt.Columns.Add("ID");
        dt.Columns["ID"].ExtendedProperties["Test"] = "Value";
        for (int i = 0; i < 10; i++)
            dt.Rows.Add(i);
        grid.DataSource = dt;
}


You can get access to ExtenderProperties as follow on ItemDataBound:
protected void grid_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
        if (e.Item is GridDataItem)
        {
            GridDataItem item = e.Item as GridDataItem;
            var column = ((DataRowView)(item.DataItem)).DataView.Table.Columns["ID"];
            string extenderValue = column.ExtendedProperties["Test"].ToString();
        }
}


Sincerely yours,
Nikolay
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.
Tags
Grid
Asked by
Paul Kavanagh
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or