私の剣道グリッドでは、ポップアップエディタで編集した後、更新ボタンが機能しません。「結果」はAjaxコールレスポンスです。私はそれをコメントし、なぜだ "読み" の部分、更新されたデータをグリッドからコントローラに渡す方法
データソースの初期化:
dataSource = new kendo.data.DataSource({
transport: {
//read: {
// url: result,
// dataType: "json"
//},
update: {
url: "/AdminTool/update_grid",
dataType: "json"
},
parameterMap: function (options, operation) {
if (operation !== "read" && options.models) {
return { models: kendo.stringify(options.models) };
}
}
},
batch: true,
pageSize: 20,
schema: {
model: {
id: "DeviceIP",
fields: {
DeviceIP: { editable: false, nullable: true },
Producer: { type: "string" },
Model: { type: "string" },
DeviceType: { type: "string" },
Description: { type: "string" },
Username: { type: "string" },
Password: { type: "string" },
PublicIP: { type: "string" },
}
}
}
});
剣道グリッド初期化:
$("#turbingrid").kendoGrid({
dataSource: result,
scrollable: false,
columns: [
{ field: 'DeviceIP', title: 'DeviceIP', width: '100px', id: 'DeviceIP' },
{ field: 'Producer', title: 'Producer', width: '80px', editor: ProductNameDropDownEditor, },
{ field: 'Model', title: 'Model', width: '120px' },
{ field: 'DeviceType', title: 'DeviceType', width: '100px', editor:deviceTypesList },
{ field: 'Description', title: 'Description', width: '100px' },
{ field: 'Username', title: 'Username',width:'120px' },
{ field: 'Password', title: 'Password', width: '100px' },
{ field: 'PublicIP', title: 'PublicIP', width: '120px' },
{ command: ["edit"], title: " ", width: "100px" }],
editable: "popup",
edit: function() {
document.getElementsByName("DeviceIP")[0].disabled = true;
},
editable: "popup"
});
コラム編集:
function ProductNameDropDownEditor(container, options) {
$('<input name="Producer" data-type="string"\">')
.appendTo(container)
.kendoDropDownList({
valuePrimitive: true,
dataSource: mydata,
dataTextField: "Text",
dataValueField: "Text",
});
}
function deviceTypesList(container, options) {
$('<input name="DeviceType" data-type="string" \">')
.appendTo(container)
.kendoDropDownList({
dataSource: mydata_deviceType,
dataTextField: "Text",
dataValueField: "Text",
//dataValueField: "ProductName",
});
}
マイコントローラー:
[HttpPost]
public ActionResult update_grid(TurbineDvce frm)
{
try
{
// TODO: Add update logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
私は何を指定する
public class TurbineDvce
{
public string TurbineId { get; set; }
public string DeviceIP { get; set; }
public string Producer { get; set; }
public string Model { get; set; }
public string DeviceType { get; set; }
public string Comments { get; set; }
public string Description { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public string PublicIP { get; set; }
}
少数のノートは、あなたがhttp://docs.telerik.com/kendo-ui/([ 'autoSync']を見てみたいことがあります。あなたの場合は
、一例は次のようになりますapi/javascript/data/datasource#configuration-autoSync)を使用して、変更が適用されるたびにサーバーを自動的に呼び出すことができます。あるいは、 'sync'を手動で呼び出すこともできます。オプションで、提供された 'transport.update'メソッドを使うか、あるいは' update'関数で[AJAX]を使うことができます(http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration- transport.update)。 – Sandman
リクエストと共に送信される['data'](http://docs.telerik.com/kendo-u/api/javascript/data/datasource#configuration-transport.update.data)を指定することができます。または、オプションで['parameter.map'](http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-transport.parameterMap)を参照してください。 – Sandman
@Sandmanありがとうございます。正直なところ、私はそれを別に書くか、私の剣道グリッドコードの間に入れなければならないか分かりません – mortezasol