How to handle foreign keys in RadGridView

5 posts, 0 answers
  1. Kranthi
    Kranthi avatar
    15 posts
    Member since:
    May 2009

    Posted 18 Aug 2009 Link to this post

    Hello Telerik team,

    I am using telerik radgridview in one of my WPF application. When i am binding Itemsource property i am binding a object which has foreign key columns, now in radgridview column i am getting the foreign key ID values as expected.

    For example:

    Binding Table Colums:
    TableID
    Name
    Description
    ForeignKeyTableID (FK)

    Foreign key table:
    ForeignKeyTableID
    Value




    Now i want to display the value of the foreign key rather than the id value, as id doesn't make any sense to display. What would be the efficient way to do this. I am thinking of using converter while binding, but it would be heavy as i will be working on thousands of records in radgrid.

    Looking for a best and efficient way to handle this...

    Thanks,
    Kranthi
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 19 Aug 2009 Link to this post

    Hello Kranthi,

    You can safely use IValueConverter to achieve this. The grid rows are UI virtual and only converters in view-port will be executed.

    Regards,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Kranthi
    Kranthi avatar
    15 posts
    Member since:
    May 2009

    Posted 22 Aug 2009 Link to this post

    Yes i can use valueconverters, but in my case, i have around 25 to 30 radgrids, and each grid consists of at least one foerign key to display.

    If i start creating Ivalueconverter for each i need to create a IValueConverter for each table. Is there any way that i can make the Ivalue converter generic such that i can use it for different objects(tables)
  5. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 22 Aug 2009 Link to this post

    Hi Kranthi,

    you say you bind "objects". This could mean a lot.
    And since you can access the Value of the "linked table" via a converter it should also be possible to access this value in property of you "base table object" something like
    public string FKTableValue {
      get { return(ResolveFKValue(ForeignKeyTableID)); }
    }

    Regards

    Manfred
  6. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 25 Aug 2009 Link to this post

    Hello Kranthi,

    Just an idea - The GridViewComboBoxColumn has a built in feature to translate foreign keys into their corresponding string representations (even when not in edit mode and when the combo editor is hidden).

    I am not sure if GridViewComboBoxColumn is applicable in your case , but if you set the column specific properties ( itemssource, displaymemberpath, selectedvaluepath etc)  you may have this behavior 'for free'.

    Sincerely yours,

    Pavel Pavlov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top
UI for WPF is Visual Studio 2017 Ready