Я хочу использовать интерфейс Kendo в Laravel. Это хорошо работает, а я не хочу делать с ним CRUD. В пакете UI (Kendo) Telerik содержатся рабочие примеры с PHP-оболочками функций CRUD, но я не могу правильно реализовать его с помощью структуры Laravel. (Покажите только пустую сетку.) В 1-м разделе контроллера создайте содержимое json, когда запрос «POST» и зависит от параметра, сделайте некоторый материал CRUD. Второй раздел создает сетку и обратно DataSourceTransport (и т. Д.) И URL-адреса, которые называются запросом «POST». Маршрут вызывает «любой» маршрут (route \ web.php), но не работает правильно. Я предполагаю, что настройки маршрута плохие, но я не знаю, что такое решение. (Я подписал "// !!!!!!!!!!!!!!!!!" раздел Опросные)Интерфейс пользователя Laravel и Kendo: URL маршрутизации для запроса в функции редактирования сетки CRUD json
GjtorzsXController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use DB;
class GjtorzsXController extends Controller
{
//
public function index()
{
$result = new \DataSourceResult('sqlite:../database/database.sqlite');//
//1st section----------------------------------------------------------
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
header('Content-Type: application/json');
$request = json_decode(file_get_contents('php://input'));
$type = $_GET['type'];
$columns = array('Rendszam', 'Tipus');
switch($type) {
case 'create':
$result = $result->create('gepjarmu', $columns, $request->models, 'id');
break;
case 'read':
$result = $result->read('gepjarmu', $columns, $request);
break;
case 'update':
$result = $result->update('gepjarmu', $columns, $request->models, 'id');
break;
case 'destroy':
$result = $result->destroy('gepjarmu', $request->models, 'id');
break;
}
echo json_encode($result);
exit;
}
//2nd section------------------------------------------------------
$transport = new \Kendo\Data\DataSourceTransport();
$create = new \Kendo\Data\DataSourceTransportCreate();
$create->url('gjtorzsx?type=create')
->contentType('application/json')
->type('POST');
$read = new \Kendo\Data\DataSourceTransportRead();
$read->url('gjtorzsx?type=read') //TestPage.php?type=read gjtorzsx?type=read
->contentType('application/json')
->type('POST');
$update = new \Kendo\Data\DataSourceTransportUpdate();
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//This url is not correct??????????????????????
$update->url('gjtorzsx?type=update') //????????????????????????????
->contentType('application/json')
->type('POST');
$destroy = new \Kendo\Data\DataSourceTransportDestroy();
$destroy->url('gjtorzsx?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();
$rendszamField = new \Kendo\Data\DataSourceSchemaModelField('Rendszam');
$rendszamField->type('string');
$tipusField = new \Kendo\Data\DataSourceSchemaModelField('Tipus');
$tipusField->type('string');
$model->id('id')
->addField($rendszamField)
->addField($tipusField;
$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(30)
->schema($schema);
$grid = new \Kendo\UI\Grid('grid');
$rendszamColumn = new \Kendo\UI\GridColumn();
$rendszamColumn->field('Rendszam')
->title('Rendszám')
->width(100);
$tipusColumn = new \Kendo\UI\GridColumn();
$tipusColumn->field('Tipus')
->title('Típus')
->width(200);
$command = new \Kendo\UI\GridColumn();
$command->addCommandItem('destroy')
->title(' ')
->width(150);
$grid->addColumn($rendszamColumn, $tipusColumn, $command)
->dataSource($dataSource)
->addToolbarItem(new \Kendo\UI\GridToolbarItem('create'),
new \Kendo\UI\GridToolbarItem('save'), new \Kendo\UI\GridToolbarItem('cancel'))
->height(540)
->navigatable(true)
->editable(true)
->groupable(true)
->pageable(true);
$args = array('grid' => $grid);
return \View::make('hello2')->with($args);
}
}
маршрут \ web.php:
Route::any('gjtorzsx', '[email protected]');
helo2.blade.php: ... {!! $ grid-> render() !!} ...
Любые сообщения об ошибках? Проверьте свои журналы. Можете ли вы обрезать это до https://stackoverflow.com/help/mcve, пожалуйста? – Robert
Нет сообщений об ошибках, только сетка пуста. Я проверяю журнал, и ошибка указана в URL-адресе маршрута: «TokenMismatchException в строке VerifyCsrfToken.php 68» Я пытаюсь решить следующее: « "> ', но не работает ... –