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

no data in the grid

9 Answers 174 Views
Grid
This is a migrated thread and some comments may be shown as answers.
William
Top achievements
Rank 1
William asked on 21 Dec 2015, 12:16 AM

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.

 

 

9 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 23 Dec 2015, 02:58 PM

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!
 
0
William
Top achievements
Rank 1
answered on 23 Dec 2015, 05:22 PM
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.
0
Alex Gyoshev
Telerik team
answered on 25 Dec 2015, 08:43 AM

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!
 
0
William
Top achievements
Rank 1
answered on 25 Dec 2015, 01:26 PM
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.
0
Alex Gyoshev
Telerik team
answered on 25 Dec 2015, 02:54 PM

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!
 
0
William
Top achievements
Rank 1
answered on 25 Dec 2015, 03:36 PM

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

 

0
Vladimir Iliev
Telerik team
answered on 29 Dec 2015, 02:00 PM
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!
 
0
William
Top achievements
Rank 1
answered on 29 Dec 2015, 04:51 PM
I already did that but it does not work, I gave up.
0
William
Top achievements
Rank 1
answered on 02 Jan 2016, 01:32 PM
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.
Tags
Grid
Asked by
William
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
William
Top achievements
Rank 1
Vladimir Iliev
Telerik team
Share this question
or