Controlling visibility / title of columns

5 posts, 1 answers
  1. Masoud
    Masoud avatar
    61 posts
    Member since:
    Aug 2011

    Posted 29 Dec 2011 Link to this post

    Hi there,

    Is it possible to retrieve the name of the property that a RadGridViewColumn is bound to via DataMemberBinding?   I need this information for two reasons:
    - show and hide columns in a grid based on the name of the property the column is bound to.  
    - set the title of a column based on the name of the property the column was bound to

    Thank you very much for your help

  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 30 Dec 2011 Link to this post

    Hello,

    You can find the name of the property as follows:

    var propertyName = column.DataMemberBinding.Path.Path;

    In this case 'column" is the one which corresponding property you want to find.

    All the best,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. Masoud
    Masoud avatar
    61 posts
    Member since:
    Aug 2011

    Posted 30 Dec 2011 Link to this post

    Hello,

    DataMemberBinding is a property of GridViewBoundColumnBase.  The Columns collection of RadGridView exposes a collection of type GridViewColumnCollection that exposes GridViewColumn which doens't expose a DataMemberBinding.  How do I get a collection of GridViewBoundColumnBase from the RadGridView?  Is it possible to obtain the GridViewBoundColumnBase the maps to a GridViewColumn?

    Thank you for your help!

    Regards
  4. Answer
    Maya
    Admin
    Maya avatar
    4062 posts

    Posted 30 Dec 2011 Link to this post

    Hi,

    Generally, you can cast each of the columns in Columns collection of RadGridView to its corresponding type. For example:

    GridViewColumnCollection columns = this.clubsGrid.Columns;
    var firstColumnPropertyName = (columns[0] as GridViewDataColumn).DataMemberBinding.Path.Path;

    What is the type of columns that you are working with ? Do you define unbound columns

    Kind regards,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  5. Masoud
    Masoud avatar
    61 posts
    Member since:
    Aug 2011

    Posted 30 Dec 2011 Link to this post

    Hi,

    thank you for the information!  I am using BoundColumns,  and am now able to retrieve the information I need!

    Best regards!

Back to Top