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
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
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
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
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