no data in the grid

10 posts, 0 answers
  1. William
    William avatar
    9 posts
    Member since:
    Jul 2012

    Posted 20 Dec 2015 Link to this post

    I followed the code in this example http://demos.telerik.com/php-ui/grid/editing-inline but although the grid appear bit there is no data inside it. Here is the code attached

    I debugged the first part of the code and found the code connect successfully to my db and return the number of rows successfully.  please advise what is the problem that prevent data to appear.

     

     

  2. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 23 Dec 2015 Link to this post

    Hello William,

    The code that sends the response needs to be at the top of the file (if ($_SERVER['REQUEST_METHOD']) { ...). Otherwise the page is sent with HTML fragments in it, which is invalid JSON, thus the grid cannot connect to it.

    Regards,
    Alex Gyoshev
    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
  4. William
    William avatar
    9 posts
    Member since:
    Jul 2012

    Posted 23 Dec 2015 in reply to Alex Gyoshev Link to this post

    I placed the first part of the code at the top but still no data appear in the grid, attached is the new code please advise.
  5. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 25 Dec 2015 Link to this post

    Hello William,

    What does the file chk_login.php contain? If it outputs any characters, the JSON response may be broken.

    Regards,
    Alex Gyoshev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  6. William
    William avatar
    9 posts
    Member since:
    Jul 2012

    Posted 25 Dec 2015 in reply to Alex Gyoshev Link to this post

    No it only check session variable and redirect to login page, I tried to place the code above this file and same result no data.
  7. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 25 Dec 2015 Link to this post

    Hello William,

    Based on what we have, we are out of ideas. Are you able to run the demos shipped with the distribution and see if you can bind the grid there to your database. If this does not guide you to the problem, please provide a isolated runnable example that we can run, so that we can provide more assistance.

    Regards,
    Alex Gyoshev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  8. William
    William avatar
    9 posts
    Member since:
    Jul 2012

    Posted 25 Dec 2015 in reply to Alex Gyoshev Link to this post

    Thanks Alex,

     I isolated the code and followed exactly this example here

    http://demos.telerik.com/php-ui/grid/editing-inline

    The grid is rendered but no data.

     

    The attachment include php and sql file for a simple table

     

  9. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 29 Dec 2015 Link to this post

    Hello,

    After inspecting the provided file it appears that the JSON response is not returned correctly to the client side - with current page setup the Html of the page is also included in the response which is invalid configuration. Please check the updated code below:

    <?php
    require_once '/wrappers/php/lib/DataSourceResult.php';
    require_once '/wrappers/php/lib/Kendo/Autoload.php';
     
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        header('Content-Type: application/json');
     
        $request = json_decode(file_get_contents('php://input'));
     
        $result = new DataSourceResult('mysql:host=localhost;dbname=db', 'root', '');
     
        $type = $_GET['type'];
     
        $columns = array('location_id', 'location_name');
     
        switch ($type) {
            case 'create':
                $result = $result->create('locations', $columns, $request->models, 'location_id');
                break;
            case 'read':
                $result = $result->read('locations', $columns, $request);
                break;
            case 'update':
                $result = $result->update('locations', $columns, $request->models, 'location_id');
                break;
            case 'destroy':
                $result = $result->destroy('locations', $request->models, 'location_id');
                break;
        }
     
        echo json_encode($result, JSON_NUMERIC_CHECK);
     
        exit;
    }
    ?>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
     
        <link rel="stylesheet" href="dist/styles/web/kendo.common.min.css" />
        <link rel="stylesheet" href="dist/styles/web/kendo.default.min.css" />
     
        <script src="dist/js/jquery.min.js"></script>
        <script src="dist/js/kendo.all.min.js"></script>
    </head>
    <body>
     
    <?php
     
    $transport = new \Kendo\Data\DataSourceTransport();
     
    ....


    Regards,
    Vladimir Iliev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  10. William
    William avatar
    9 posts
    Member since:
    Jul 2012

    Posted 29 Dec 2015 in reply to Vladimir Iliev Link to this post

    I already did that but it does not work, I gave up.
  11. William
    William avatar
    9 posts
    Member since:
    Jul 2012

    Posted 02 Jan Link to this post

    I finally found the problem, the field names are capitals in the code while in the database they are small, you should made the grid to work with any field name case.
Back to Top
UI for ASP.NET AJAX banner