Kar*_*idi 11 asp.net-mvc asp.net-mvc-3 kendo-ui
我正在使用asp.net mvc.我试图在Kendo mvc ui网格中显示消息列表.我编写了代码,
Html.Kendo().Grid((List<messages>)ViewBag.Messages))
.Name("grdIndox")
.Sortable(m => m.Enabled(true).SortMode(GridSortMode.MultipleColumn))
.HtmlAttributes(new { style = "" })
.Columns(
col =>
{
col.Bound(o => o.RecNo).HtmlAttributes(new { style = "display:none" }).Title("").HeaderHtmlAttributes(new { style = "display:none" });
col.Bound(o => o.NoteDate).Title("Date").Format("{0:MMM d, yyyy}");
col.Bound(o => o.PatName).Title("Patient");
col.Bound(o => o.NoteType).Title("Type");
col.Bound(o => o.Subject);
}
)
.Pageable()
.Selectable(sel => sel.Mode(GridSelectionMode.Single).Type(GridSelectionType.Row))
.DataSource(
ds => ds.Ajax().ServerOperation(false).Model(m => m.Id(modelid => modelid.RecNo))
.PageSize(10)
//.Read(read => read.Action("Messages_Read", "Msg"))
)
.Events(ev => ev.Change("onSelectingGirdRow"))
)
Run Code Online (Sandbox Code Playgroud)
我有像IsRead-boolean类型的表中的字段.所以,如果消息是未读消息,那么我需要用粗体字格式化该记录.我已经使用了clientTemplates但是我只能格式化特定的单元格,我希望格式化整行.请指导我.
Pet*_*bev 18
正如Sanja建议您可以使用dataBound事件,但循环遍历tr元素(行)会更好.此外,我假设您将需要相关的dataItem来检查是否指示消息是否被读取的属性.
例如
dataBound: function ()
{
var grid = this;
grid.tbody.find('>tr').each(function(){
var dataItem = grid.dataItem(this);
if(!dataItem.IsMessageRead)
{
$(this).addClass('someBoldClass');
}
})
}
Run Code Online (Sandbox Code Playgroud)
您可以使用dataBound事件来更改行.
dataBound: function ()
{
$('td').each(function(){
if(some condition...)
{
$(this).addClass('someBoldClass')}
}
})
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12578 次 |
| 最近记录: |