Laravelで剣道UIを使用したい。私はCRUDのことをしたいとは思っていませんが、それは良い仕事です。 Telerik UI(剣道)パッケージには、PHPラッパーのCRUD関数の使用例が含まれていますが、Laravelフレームワークで正しく実装することはできません。 (空のグリッドだけを表示します)コントローラーの第1セクションでは、要求が 'POST'のときにjsonコンテンツを作成し、パラメーターに応じてCRUDを行います。 2番目のセクションでは、グリッドと背面のDataSourceTransport(など)と、「POST」リクエストと呼ばれるURLを作成します。ルートは 'any'ルート(route \ web.php)を呼び出しますが、正しく動作しません。私は、ルートの設定が悪いと思いますが、私は解決策が何であるか分かりません。Laravelと剣道UIグリッド:グリッド編集機能で要求する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行目です'解決策を試してみます: '"しかし、動作しません... –