Javascript 启用单元格编辑剑道网格
我很不好意思提出这样的问题,但我绝望了。我是剑道新手,我很容易使我的网格可编辑。 这是我的密码Javascript 启用单元格编辑剑道网格,javascript,asp.net-mvc,kendo-grid,Javascript,Asp.net Mvc,Kendo Grid,我很不好意思提出这样的问题,但我绝望了。我是剑道新手,我很容易使我的网格可编辑。 这是我的密码 @(Html.Kendo().Grid<Server.Models.MasterFoo>() .Name("gridRules") .HtmlAttributes(new { style = "height:300px; margin: 0px" }) .Columns(columns => {
@(Html.Kendo().Grid<Server.Models.MasterFoo>()
.Name("gridRules")
.HtmlAttributes(new { style = "height:300px; margin: 0px" })
.Columns(columns =>
{
columns.Bound(c => c)
.ClientTemplate("<input type='checkbox' class='checkbox' />")
.Width(24);
columns.Bound(c => c.ID)
.Hidden(true);
columns.Bound(c => c.Name);
columns.Bound(c => c.Description)
.EditorTemplateName("Descriptions")
.Title("SpecialDescription");
})
.DataSource(ds => ds
.Ajax()
.Model(m =>
{
m.Id(f => f.ID);
m.Field(f => f.Name).Editable(true);
m.Field(f => f.Description).Editable(true);
})
.Read(read => read.Action("GetFooBar", "MyController", new { area = "Administration" })
.Data("foo.param"))
.Update(update => update.Action("UpdateFoo", "MyController", new { area = "Administration" })
.Data("foo.param"))
.Batch(true)
)
.Events(events => events
.SaveChanges("foo.gridChanged")
//.Edit("foo.gridChanges")
//.Change("foo.gridSelection")
.DataBound("foo.gridDataBound")
)
.Resizable(r => r.Columns(true))
.Scrollable()
.Navigatable()
//.Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
.AutoBind(false)
.Sortable(sortable => sortable.AllowUnsort(false))
//.Editable(editable => editable.Mode(GridEditMode.InCell))
)
@(Html.Kendo().Grid())
.名称(“网格规则”)
.HtmlAttributes(新的{style=“高度:300px;边距:0px”})
.列(列=>
{
columns.Bound(c=>c)
.ClientTemplate(“”)
.宽度(24);
columns.Bound(c=>c.ID)
.隐藏(真实);
columns.Bound(c=>c.Name);
columns.Bound(c=>c.Description)
.EditorTemplateName(“说明”)
.标题(“特殊说明”);
})
.DataSource(ds=>ds
.Ajax()
.Model(m=>
{
m、 Id(f=>f.Id);
m、 字段(f=>f.Name)。可编辑(true);
m、 字段(f=>f.Description)。可编辑(true);
})
.Read(Read=>Read.Action(“GetFooBar”、“MyController”、new{area=“Administration”})
.Data(“foo.param”))
.Update(Update=>Update.Action(“UpdateFoo”,“MyController”,new{area=“Administration”})
.Data(“foo.param”))
.Batch(真)
)
.Events(Events=>Events
.SaveChanges(“foo.gridChanged”)
//.Edit(“foo.gridChanges”)
//.Change(“foo.gridSelection”)
.DataBound(“foo.gridDataBound”)
)
.可调整大小(r=>r.Columns(true))
.Scrollable()
.Navigatable()
//.Selectable(可选=>Selectable.Mode(GridSelectionMode.Single))
.AutoBind(假)
.Sortable(Sortable=>Sortable.alloworst(false))
//.Editable(Editable=>Editable.Mode(GridEditMode.InCell))
)
现在我遇到了一个问题:我无法编辑我的网格。
如果我添加//.Editable(Editable=>Editable.Mode(GridEditMode.InCell)),它根本不起作用。我在使用剑道2013年第2季度,我错过了什么?
提前谢谢
更新以下是每当我启用Editable(Editable=>Editable.Mode(GridEditMode.InCell))
此代码很好:
.Editable(editable => editable.Mode(GridEditMode.InCell))
但您还需要工具栏中的“保存”按钮:
.ToolBar(toolbar =>
{
toolbar.Save();
})
剑道文档摘录:
- 通过设置启用内联单元格编辑:.Editable(Editable=>Editable.Mode(GridEditMode.InCell))启用添加新记录,保存 通过设置工具栏上的“更改”和“放弃更改”按钮: .ToolBar(ToolBar=>{ToolBar.Create();ToolBar.Save();}
- 在数据源声明中设置.Batch(true)和.ServerOperation(false)属性,以启用批更新并执行分页, 客户端上的排序、筛选和分组操作
- 在数据源中调用CRUD操作方法
发现我只需要在模型中添加无参数构造函数
public class MasterFoo {
public MasterFoo() {}
}
以下是我学到的教训:
您只需将以下内容添加到columns集合中:
columns.Command(c=>c.Edit());
这将为您启用编辑按钮。我要做的是直接在单元格上编辑它,我有一个工具栏按钮,其中包括“保存”按钮,并将在每次添加时验证更改并保存所有有效更改。可编辑(editable=>editable.Mode(GridEditMode.InCell))我的单元格变了。我的程序坏了。我的文本变为绿色