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

Dynamic columns and IValueConverter

5 Answers 118 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Darkman.CV
Top achievements
Rank 1
Darkman.CV asked on 17 Mar 2010, 12:37 PM
Hi, Everybody
I need suggest how to deal following case:
I have a GridView that have a bind to collection of dynamyc objects. Thous objects can contains other complex objects.

For example:
class dynamicOne
{
    public string F1 { get; set;}
    public dynamicTwo { get; set;}
}

class dynamycTwo
{
   public string F2 { get; set;}
}

Thus, if I will bind directly to collection within these objects I will have two collumns that displays: string & dynamicTwo. I need approach to apply some kind of converter to second value (dynamycTwo).



5 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 17 Mar 2010, 12:51 PM
Hello Darkman.CV,

You can create an IValueConverter for the DataMemberBinding of the column that is bound to dynamicTwo. In the Convert method of the converter you will receive the instance of dynamicTwo and you can return anything that you like, for example its F2 value.

I hope this helps.

All the best,
Ross
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Darkman.CV
Top achievements
Rank 1
answered on 17 Mar 2010, 01:46 PM
Ok, How I can use DataMemberBinding property when AutoGenerateColumns property is use?
I need use converter for dynamic generated columns.
0
Vlad
Telerik team
answered on 17 Mar 2010, 01:51 PM
Hello Darkman.CV,

You can catch AutoGeneratingColumn event to modify auto-generated columns.

Regards,
Vlad
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Darkman.CV
Top achievements
Rank 1
answered on 17 Mar 2010, 02:17 PM
Can you share an example how I can to do this?
0
Rossen Hristov
Telerik team
answered on 17 Mar 2010, 02:48 PM
Hi Darkman.CV,

this.radGridView.AutoGeneratingColumn += new EventHandler<GridViewAutoGeneratingColumnEventArgs>(radGridView_AutoGeneratingColumn);

void radGridView_AutoGeneratingColumn(object sender, GridViewAutoGeneratingColumnEventArgs e)
        {
            GridViewBoundColumnBase column = e.Column as GridViewBoundColumnBase;
            if (column != null)
            {
                column.DataMemberBinding.Converter = new DynamicTwoToStringConverter();
            }
        }

It is up to you to implement your converter. We do not know what you want to do inside.

I hope this helps.

Best wishes,
Ross
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Darkman.CV
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Darkman.CV
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or