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

Foreign Key with two datasources

2 Answers 240 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Philipp
Top achievements
Rank 1
Philipp asked on 26 Aug 2017, 08:08 AM

Hi,

please help me. I'm trying to setup a grid with a foreign key column. Why this don't work? http://jsfiddle.net/f6tvxjft/2/

And why i get no data from dataSource2 after clicking on "Get Data" button?

Regards,

Philipp

2 Answers, 1 is accepted

Sort by
0
Preslav
Telerik team
answered on 29 Aug 2017, 08:33 AM
Hi Philipp,

Generally speaking, the columns.values configuration cannot accept Kendo dataSource as a parameter, it accepts an array. More information about this is available here:
That said, the correct syntax in the Grid should be:

var grid = $("#grid").kendoGrid({
    dataSource: dataSource, 
    scrollable: false,   
    columns: [
        { field: "id" },
      { field: "text" },
      { field: "category", values: categories}
      ]           
}).data("kendoGrid");

Furthermore, in the click event handler, there is no data in the second dataSource because the data is not yet populated in it as there was no read method invoked.

The Grid programmatically invokes the read method thus, there is data in the first dataSource.

Having said that, manually invoke the read method to populate the data in the second dataSource. For example:

$('#data').on('click', function(){
  dataSource2.read()
  console.log(JSON.stringify(dataSource.data()));
  console.log(JSON.stringify(dataSource2.data()));
});

Finally, a runnable example of the ForeignKey column functionality is available in this Demo:
I hope this information helps.
 

Regards,
Preslav
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Philipp
Top achievements
Rank 1
answered on 31 Aug 2017, 06:35 AM

Thanks a lot.

Regards,

Philipp 

Tags
Grid
Asked by
Philipp
Top achievements
Rank 1
Answers by
Preslav
Telerik team
Philipp
Top achievements
Rank 1
Share this question
or