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

Displaying foreign key value in ClientRowTemplate of KendoUI Grid

3 Answers 393 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 12 Dec 2012, 03:29 AM
How do I go about showing the value of the foreign key (not the ID) within the ClientRowTemplate of a Grid?

3 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 13 Dec 2012, 03:03 PM
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.
e.g.
Text is : #= getTextByValue(data)#


Regards,
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!
0
pratik
Top achievements
Rank 1
answered on 03 Oct 2015, 05:24 AM

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

 

Your Regard,

Pratik R. Panchal

0
Boyan Dimitrov
Telerik team
answered on 07 Oct 2015, 07:45 AM

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? 

 

Regards,
Boyan Dimitrov
Telerik
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
Tags
Grid
Asked by
Steven
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
pratik
Top achievements
Rank 1
Boyan Dimitrov
Telerik team
Share this question
or