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

Grid with linked tables

1 Answer 93 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paolo
Top achievements
Rank 1
Paolo asked on 11 Nov 2015, 12:39 PM

I am building a test app with kendo ui php.
I am using a grid following the examples I have found on telerik web site.

The grid works correctly on a single table, but I am not able to get it working if I try adding a field from another table.

In the example I have, which is working correctly, you set the read table fields in this way:

 

$read_columns = array(<br>    'p.ProductID', <br>    'p.ProductName', <br>    'p.UnitPrice', <br>    'p.UnitsInStock', <br>    'p.SupplierID',<br>    '(select s.CompanyName From Suppliers s Where s.SupplierID = p.SupplierID) as SupplierName',<br>    'p.CategoryID',<br>    '(select c.CategoryName From Categories c Where c.CategoryID = p.CategoryID) as CategoryName',<br>  );​

 I was able to setup the datagrid without foreign fields:

 

$read_columns2 = array(<br> 'idAnagraficaPDV',<br>'data',<br> 'ora',<br> 'downloadStatusId',<br>//'(select s.descrizione From downloadstatus s Where s.downloadStatusId = d.downloadStatusId) as downloadstatus',<br>  // '(Select s.descrizione From downloadstatus s  Where s.downloadStatusId IN (Select d.downloadStatusId From d)) as descrizione'<br> //    '(Select s.descrizione From downloadstatus s  Where s.downloadStatusId IN (Select d.downloadStatusId From downloadlogs d))'<br><br><br>  );​

but if I try adding the foreign fields - removing the comments from one of the commented lines, I get no more data in datagrid. Note that the script passes to the browser a json array with the correct count of records but without data:

{"total":2,"data":[]}​

while removing commenting the query line it retrieves the correct data, but of course without the field I need:

{"total":3,"data":[{"idAnagraficaPDV":"2","data":"2015-11-07","ora":"15:55:00","downloadStatusId":"1"},{"idAnagraficaPDV":"2","data":"2015-10-06","ora":"06:20:00","downloadStatusId":"2"},{"idAnagraficaPDV":"2","data":"2015-11-09","ora":"05:00:07","downloadStatusId":"3"}]}​

 

Note the query I have set in string works correctly in the database.

Any suggestion?

 

1 Answer, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 16 Nov 2015, 07:37 AM
Hello,

Please accept my apologies for the delayed response.

The UI for PHP Grid will not evaluate inline SQL in column names. You have to execute the query in advance and populate the column names with the resulting values.

I hope this helps.

Regards,
T. Tsonev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Paolo
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Share this question
or