Hello,
I have a condiderble issue with Kendo UI Grid.
First of all, it loads data by AJAX call after loading grid itself instead od loading and inserting data on server.
But back to my issue, with this code, my grid is generated, it calls AJAX request, but it doesn't show them in grid.
Code:
$transport = new \Kendo\Data\DataSourceTransport();
$read = new \Kendo\Data\DataSourceTransportRead();
$read->url('http://127.0.0.1/api/records')
->contentType('application/json')
->type('GET');
$create = new \Kendo\Data\DataSourceTransportCreate();
$create->url('http://127.0.0.1/api/records')
->contentType('application/json')
->type('POST');
$update = new \Kendo\Data\DataSourceTransportUpdate();
$update->url('http://127.0.0.1//api/records')
->contentType('application/json')
->type('UPDATE');
$destroy = new \Kendo\Data\DataSourceTransportDestroy();
$destroy->url('http://185.33.145.45/api/records')
->contentType('application/json')
->type('DELETE');
$transport
->read($read)
->create($create)
->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);
$nameField = new \Kendo\Data\DataSourceSchemaModelField('name');
$nameField->type('string')
->validation(array('required' => true));
$YearField = new \Kendo\Data\DataSourceSchemaModelField('year');
$YearField->type('number')
->editable(true)
->nullable(true);
$model
->addField($IDField)
->addField($YearField)
->addField($nameField);
$schema = new \Kendo\Data\DataSourceSchema();
$schema->data('data')
->errors('errors')
->model($model)
->total('total');
$dataSource = new \Kendo\Data\DataSource();
$dataSource
->transport($transport)
->pageSize(30)
->schema($schema);
$grid = new \Kendo\UI\Grid('grid');
$name = new \Kendo\UI\GridColumn();
$name
->field('name')
->title('název');
$year = new \Kendo\UI\GridColumn();
$year
->field('year')
->title('rok vydání');
$excel = new \Kendo\UI\GridExcel();
$excel->fileName('Kendo UI Grid Export.xlsx')
->filterable(true)
->proxyURL('excel-export.php?type=save');
$grid
->addColumn($name, $year)
->dataSource($dataSource)
->excel($excel)
->groupable(true)
->sortable(true)
->filterable(true)
->navigatable(true)
->editable(true)
->pageable(true)
->addToolbarItem(new \Kendo\UI\GridToolbarItem('create'),
new \Kendo\UI\GridToolbarItem('save'), new \Kendo\UI\GridToolbarItem('cancel'))
->height(400);
$gridHTML = $grid->render();