1
我有KendoUI网格在MVC4应用,如下所示:选择的DataItem在剑道UI网格
@(Html.Kendo().Grid<ProjectSystem.Web.Models.ProjectModel>()
.Name("Grid")
.Editable(editable =>
{
if(User.IsInRole(Constants.Admin))
{
editable.Mode(GridEditMode.InCell);
}
else
{
editable.Enabled(false);
}
})
.Sortable(sortable => sortable.AllowUnsort(false))
.Navigatable()
.ToolBar(toolbar =>
{
if (User.IsInRole(Constants.Admin))
{
toolbar.Create();
toolbar.Save();
}
})
.Selectable(s => s.Mode(GridSelectionMode.Single).Type(GridSelectionType.Row))
.Columns(columns =>
{
columns.Bound(p => p.ProjectId);
columns.Bound(p => p.Name);
columns.Bound(p => p.Address);
columns.Bound(p => p.Postcode);
columns.Bound(p => p.Contact);
columns.Bound(p => p.Files);
columns.Bound(p => p.Link).ClientTemplate("<a href='#=Link#' target='_blank'>#=Files!=null && Files.length > 0 ? 'Dropbox' : '' #</a>");
columns.Bound(p => p.ProjectStatus);
columns.Bound(p => p.Active).ClientTemplate("<input type='checkbox' class='chkboxActive' #= Active ? checked='checked' : '' # ></input>");
columns.Bound(p => p.Unused).ClientTemplate("<input type='checkbox' class='chkboxUnused' #= Unused ? checked='checked' : '' # ></input>");
columns.Bound(p => p.IsSMS).ClientTemplate("<input type='checkbox' class='chkboxIsSMS' #= IsSMS ? checked='checked' : '' # ></input>");
columns.Bound(p => p.MaterialLink).Title("").ClientTemplate("<a href='/Material/index?projectId=#=ProjectId#'>#=GetText()#</a>");
})
.DataSource(dataSource => dataSource.Ajax()
.Model(model => model.Id(p => p.ProjectId))
.Batch(true)
.Events(events => events.Error("error"))
.Events(events => events.RequestEnd("onRequestEnd"))
.Create(create => create.Action("ProjectCreate", "Project"))
.Update(update => update.Action("ProjectUpdate", "Project"))
.Read(read => read.Action("ProjectRead", "Project").Data("ExtraData"))
)
)
的ProjectStatus列是一个枚举,其具有UIHint称为StatusColumn;既shwon这里:
枚举:
public enum ProjectStatus
{
Open = 1,
Closed = 2
}
视图模型:
[UIHint("StatusColumn")]
[Display(Name = "Status")]
public ProjectStatus ProjectStatus { get; set; }
的UIHint(部分图):
@(Html.Kendo().DropDownList().Name("ProjectStatus")
.BindTo(new List<DropDownListItem>
{
new DropDownListItem{Text = "", Value = "0"},
new DropDownListItem{Text = "Open", Value = "1"},
new DropDownListItem{Text = "Closed", Value = "2"}
}
).Events(e => e.Select("saveProjectStatus")))
* 的问题:*
我其实想获得专案编号值(在上面显示网格列),当saveProjectStatus事件在上图所示的下拉UI提示解雇。
我设法选择的值如下:
function saveProjectStatus(e) {
debugger;
var grid = e.sender;
var row = grid.select();
var currentDataItem = grid.dataItem(this.select());
var selectedValue = currentDataItem.Text;
// var data = grid.dataItem("tr:eq(1)");
// var dataItem = grid.dataItem($(this).closest('tr'));
// var uid = currentDataItem.uid; //.Name;
// var dataContext = grid.dataSource.getByUid(uid);
// var parentRow = e.wrapper.closest("tr");
//var uid = $(e)parent().parent().attr('data-uid');
//var dataContext = grid.dataSource.getByUid(uid);
}
但我不能为专案编号做同样的!在过去的一个小时里,我曾尝试过几次(都是上面提到的),但没有成功。
我也很高兴在DOM中隐藏行而不是获取ProjectId,如果这也是可以的。
如果可以,请帮助。
非常感谢提前。
@C更清晰没有下拉列表仅在一列中,是的,我想要捕获该行的Id或将其从dom中隐藏。谢谢。 –
该功能将让您访问选定的行项目ID – CSharper
我从哪里来的? @C Sharper –