KendoUi-grid に少し問題があります。それは非常に簡単です:
JS ファイル
$("#gridPlannif").kendoGrid({
datasource: ds_VEHICULE_SANSDATEFIN,
height: 200,
toolbar: ["create"],
sortable: true,
filterable: true,
scrollable: true,
columns: [{
field: "sDateArriveePrevue",
title: "Arrivée à partir du",
}, {
[... some columns... ]
},{
command: ["edit", "destroy"], title: " ", width: "200px" }
],
editable: {
mode: "popup",
[... some configurations ... ]
}
});
コントローラー
public ActionResult UpdateVehicule([DataSourceRequest]DataSourceRequest request, Planification vehicule)
{
try
{
if (this.ModelState.IsValid)
{
[...]
}
else
{
[...]
}
return Json(new[] { vehicule }.ToDataSourceResult(request, ModelState));
}
catch (Exception e)
{
return Json(new[] { vehicule });
}
}
ビュー (.ascx)
[...]
<script>
ds_VEHICULE_SANSDATEFIN = new kendo.data.DataSource({
autoSync: true,
transport: {
read: {
url: '<%= Url.Action("GetVehicules_SansDateFin", "Plannification") %>'
},
update: {
url: '<%= Url.Action("UpdateVehicule", "Plannification") %>'
},
destroy: {
url: '<%= Url.Action("DeleteVehicule", "Plannification") %>'
},
create: {
url: '<%= Url.Action("AddVehicule", "Plannification") %>'
}
}
});
</script>
[...]
問題
-> 最初の問題: データソース定義が機能しません。グリッドの初期化後にその手順を実行する必要があります:
$("#gridPlannif").data("kendoGrid").setDataSource(ds_VEHICULE_SANSDATEFIN);
$("#gridPlannif").data("kendoGrid").dataSource.read();
$("#gridPlannif").data("kendoGrid").refresh();
そのおかげで、グリッドはデータを正しく表示します。
-> 2 番目の問題、最も重要な問題: 「追加」、「編集」、および「破棄」がコントローラーを呼び出さない。firebug を使用すると、コントローラーへの呼び出しが表示されません。理由はわかりません。同じページで Scheduler コンポーネントを使用していますが、動作します。コントローラーで同じ機能を使用して、追加/更新/削除します。
誰か提案がありますか?
ありがとうございました。