Displaying foreign key value in ClientRowTemplate of KendoUI Grid

4 posts, 0 answers
  1. Steven
    Steven avatar
    1 posts
    Member since:
    Mar 2012

    Posted 11 Dec 2012 Link to this post

    How do I go about showing the value of the foreign key (not the ID) within the ClientRowTemplate of a Grid?
  2. Petur Subev
    Petur Subev avatar
    1882 posts

    Posted 13 Dec 2012 Link to this post

    Hello Steven,

    The KeyValuePairs (ID/Value) for particular ForeignKey column could be found the following way:

    var collection; // global object which you can use as dictionary to get text for particular id
      function getTextByValue(data) {
          //if the collection is empty - get it from the grid
          if (!collection) {
              grid = $("#GridName").data("kendoGrid");
               valuesCollection = grid.options.columns[1].values;//Set the correct FKColumn index
              collection = {};           
              for (var value in valuesCollection) {
                  collection[valuesCollection[value].value] = valuesCollection[value].text;
          return collection[data.EmployeeID];

    You can use the function in yourRow template and pass the data to it to retrieve the Text.
    Text is : #= getTextByValue(data)#

    Petur Subev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. pratik
    pratik avatar
    1 posts
    Member since:
    Sep 2015

    Posted 03 Oct 2015 in reply to Petur Subev Link to this post

    Can You Give Me a Demo Project of Foreign key use within the ClientRowTemplate of a Kendo Grid ?


    Your Regard,

    Pratik R. Panchal

  4. Boyan Dimitrov
    Boyan Dimitrov avatar
    2062 posts

    Posted 07 Oct 2015 Link to this post

    Hello pratik,


    I am not able to understand completely the functionality you are trying to achieve. Could you please elaborate a bit more on your scenario? 


    Boyan Dimitrov
    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 Feedback Portal and vote to affect the priority of the items
Back to Top