Grid with linked tables

2 posts, 0 answers
  1. Paolo
    Paolo avatar
    26 posts
    Member since:
    Nov 2015

    Posted 11 Nov 2015 Link to this post

    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?

     

  2. T. Tsonev
    Admin
    T. Tsonev avatar
    2772 posts

    Posted 16 Nov 2015 Link to this post

    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!
     
  3. UI for ASP.NET AJAX banner
Back to Top