Kendo UI Grid を使用しています。基本的に、私がやりたいことは、json 形式で送信されるリモート データにグリッドをバインドし、それを編集できるようにすることです。グリッドはデータを受け取り、必要に応じて表示します。しかし、セルを編集したいとき、phpファイルで受け取ったリクエストはnullで、送信されたタイプは「作成」ですが、「更新」にしたいのです。
使用されるコードは次のとおりです。 - JavaScript にはグリッド宣言が含まれています。
$(document).ready(function() {
var dataSource = new kendo.data.DataSource({
batch: true,
transport: {
read: {
dataType: "json",
type: "POST",
url: "testgrid.php?type=read"
},
update: {
dataType: "json",
type: "POST",
url: "testgrid.php?type=update"
},
create: {
dataType: "json",
type: "POST",
url: "testgrid.php?type=create"
},
destroy: {
dataType: "json",
type: "POST",
url: "testgrid.php?type=destroy"
}
},
schema: {
data: function(result) {
return result.Result || result.data;
},
model: {
id: "bbmindex",
fields: {
totalvente: {type: "number"}
}
},
total: function(result) {
return result.totalData || result.PageSize || result.length || 0;
}
}
});
var param = {
columns: [
{
field: "naturetravaux", title: "nature travaux"
},
{
field: "totalvente", title: "total vente"
}
],
selectable: 'multiplerows',
editable: true,
toolbar: ["create", "save", "cancel", "destroy"],
dataSource: dataSource
};
$("#grid").kendoGrid(param);
});
-phpスクリプトはデータをdataSourceに送信します
<?php
header('Content-Type: application/json');
$request = json_decode(file_get_contents('php://input'));
$type = $_GET['type'];
$result = null;
if ($type == 'create') {
some code
} else if ($type == 'read') {
some code which send the data
} else if ($type == 'update') {
some code
}
echo json_encode($result);
?>
ここで何が間違っているかについて何か考えはありますか? どんな助けでも大歓迎です、事前に感謝します
マーティン