Hi, I used the sample code for inline editing and just change some parameters but the gird doesn't populate any data. Can you help help me ?
This is my code:
<!DOCTYPE html>
<
html
>
<
head
>
<
title
></
title
>
<
link
rel
=
"stylesheet"
href
=
"styles/kendo.common.min.css"
/>
<
link
rel
=
"stylesheet"
href
=
"styles/kendo.default.min.css"
/>
<
link
rel
=
"stylesheet"
href
=
"styles/kendo.dataviz.min.css"
/>
<
link
rel
=
"stylesheet"
href
=
"styles/kendo.dataviz.default.min.css"
/>
<
script
src
=
"js/jquery.min.js"
></
script
>
<
script
src
=
"js/kendo.all.min.js"
></
script
>
</
head
>
<
body
>
<?
php
require_once 'includes/lib/DataSourceResult.php';
require_once 'includes/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('');
$type = $_GET['type'];
$
columns
=
array
('ID', 'Control_Name', 'English_Description' );
switch($type) {
case 'create':
$result = $result->create('controls_name', $columns, $request->models, 'ID');
break;
case 'read':
$result = $result->read('controls_name', $columns, $request);
break;
case 'update':
$result = $result->update('controls_name', $columns, $request->models, 'ID');
break;
case 'destroy':
$result = $result->destroy('controls_name', $request->models, 'ID');
break;
}
echo json_encode($result, JSON_NUMERIC_CHECK);
exit;
}
$transport = new \Kendo\Data\DataSourceTransport();
$create = new \Kendo\Data\DataSourceTransportCreate();
$create->url('kendoTest2.php?type=create')
->contentType('application/json')
->type('POST');
$read = new \Kendo\Data\DataSourceTransportRead();
$read->url('kendoTest2.php?type=read')
->contentType('application/json')
->type('POST');
$update = new \Kendo\Data\DataSourceTransportUpdate();
$update->url('kendoTest2.php?type=update')
->contentType('application/json')
->type('POST');
$destroy = new \Kendo\Data\DataSourceTransportDestroy();
$destroy->url('kendoTest2.php?type=destroy')
->contentType('application/json')
->type('POST');
$transport->create($create)
->read($read)
->update($update)
->destroy($destroy)
->parameterMap('function(data) {
return kendo.stringify(data);
}');
$model = new \Kendo\Data\DataSourceSchemaModel();
$IDField = new \Kendo\Data\DataSourceSchemaModelField('ID');
$IDField->type('number')
->editable(false);
//->nullable(true);
$controlNameField = new \Kendo\Data\DataSourceSchemaModelField('Control_Name');
$controlNameField->type('string');
// ->validation(array('required' => true));
$model->id('ID')
->addField($IDField)
->addField($controlNameField);
$schema = new \Kendo\Data\DataSourceSchema();
$schema->data('data')
->errors('errors')
->model($model)
->total('total');
$dataSource = new \Kendo\Data\DataSource();
$dataSource->transport($transport)
->batch(true)
->pageSize(20)
->schema($schema);
$grid = new \Kendo\UI\Grid('grid');
$controlName = new \Kendo\UI\GridColumn();
$controlName->field('Control_Name')
->title('Control Name');
$command = new \Kendo\UI\GridColumn();
$command->addCommandItem('edit')
->addCommandItem('destroy')
->title(' ')
->width(172);
$grid->addColumn($controlName, $command)
->dataSource($dataSource)
->addToolbarItem(new \Kendo\UI\GridToolbarItem('create'))
->height(430)
->editable('inline')
->pageable(true);
echo $grid->render();
?>
</
body
>
</
html
>