Kendo ui 剑道网格行以默认样式渲染
我的网格是Kendo ui 剑道网格行以默认样式渲染,kendo-ui,kendo-grid,kendo-asp.net-mvc,Kendo Ui,Kendo Grid,Kendo Asp.net Mvc,我的网格是 @(Html.Kendo().Grid<student.Models.SearchViewModel>() .Name("Grid").HtmlAttributes(new { @class = "studentGrid" }) .Columns( x => { x.Bound(y => y.Id)
@(Html.Kendo().Grid<student.Models.SearchViewModel>()
.Name("Grid").HtmlAttributes(new { @class = "studentGrid" })
.Columns(
x =>
{
x.Bound(y => y.Id).Hidden(true);
x.Bound(y => y.Id).ClientTemplate(@"<input type='checkbox' name='checkedRecords' value='#= Id #' class='mainCheckbox' onclick='checkboxClicked(this, ""checkAllMain"")'/>")
.Title("")
.HeaderTemplate(@"<input type='checkbox' name='checkAllMain' onclick='selectAll(this, ""mainCheckbox"");' />")
.HeaderHtmlAttributes(new { style = "text-align:center" })
.Filterable(false)
.Sortable(false)
.HtmlAttributes(new { @class = "checboxClass", style = "text-align:center" });
x.Bound(y => y.abc1).Hidden(false);
x.Bound(y => y.abc2).Hidden(false);
x.Bound(y => y.abc3).Hidden(false);
}
)
.ToolBar(tb =>
{
tb.Custom()
.Text("Export To Excel")
.HtmlAttributes(new { id = "export" })
.Url(Url.Action("Export", Html.CurrentControllerName()));
tb.Custom()
.Text("Expand Selected Rows")
.HtmlAttributes(new { id = "expandSelectedRows" });
})
.Groupable()
.Reorderable(x => x.Columns(true))
.Pageable(x => x.PageSizes(new int[] { 20, 50, 100 }).Input(true).Numeric(true))
.Scrollable(x => x.Enabled(true).Height(Model.Height))
.Resizable(resize => resize.Columns(true))
.Reorderable(reorder => reorder.Columns(true))
.Sortable()
.Selectable()
.Navigatable()
.Filterable()
.ClientDetailTemplateId("subTemplate")
.AutoBind(!Model.NoAutoload)
.Events(ev => { ev.DataBound("DataBoundSearch"); })
.DataSource(dataSource => dataSource
.Ajax().PageSize(100)
.ServerOperation(false) // Paging, sorting, filtering and grouping will be done client-side
.Model(model => model.Id(c => c.Id))
.Events(events => events.Error("error").RequestStart("RequestStart").RequestEnd("RequestEnd").Change("Changed"))
.Read(x => x.Action("GetData", Html.CurrentControllerName()).Data("ABCPostData")))
)
@(Html.Kendo().Grid())
.Name(“网格”).HtmlAttributes(新的{@class=“studentGrid”})
.栏目(
x=>
{
x、 绑定(y=>y.Id).隐藏(true);
x、 绑定(y=>y.Id).ClientTemplate(@“”)
.标题(“”)
.HeaderTemplate(@“”)
.HeaderHtmlAttributes(新的{style=“text align:center”})
.可过滤(错误)
.Sortable(false)
.HtmlAttributes(新的{@class=“checboxClass”,style=“text align:center”});
x、 绑定(y=>y.abc1)。隐藏(false);
x、 绑定(y=>y.abc2)。隐藏(false);
x、 绑定(y=>y.abc3)。隐藏(false);
}
)
.工具栏(tb=>
{
tb.Custom()
.Text(“导出到Excel”)
.HtmlAttributes(新的{id=“导出”})
.Url(Url.Action(“导出”,Html.CurrentControllerName());
tb.Custom()
.Text(“展开所选行”)
.HtmlAttributes(新的{id=“expandSelectedRows”});
})
.Groupable()
.Reorderable(x=>x.Columns(true))
.Pageable(x=>x.PageSizes(新的int[]{20,50,100}).输入(true).数字(true))
.Scrollable(x=>x.Enabled(true).Height(Model.Height))
.resize可调整大小(resize=>resize.Columns(true))
.Reorderable(reorder=>reorder.Columns(true))
.Sortable()
.可选()
.Navigatable()
.可过滤()
.ClientDetailTemplateId(“子模板”)
.AutoBind(!Model.NoAutoload)
.Events(ev=>{ev.DataBound(“DataBoundSearch”);})
.DataSource(DataSource=>DataSource
.Ajax().PageSize(100)
.ServerOperation(false)//分页、排序、筛选和分组将在客户端完成
.Model(Model=>Model.Id(c=>c.Id))
.Events(Events=>Events.Error(“Error”).RequestStart(“RequestStart”).RequestEnd(“RequestEnd”).Change(“Changed”))
.Read(x=>x.Action(“GetData”,Html.CurrentControllerName()).Data(“ABCPostData”))
)
当我们选择一行时,默认情况下,该行以棕色突出显示。单击该行时,我无法获取默认颜色。在客户端,它呈现为
<tr class="k-master-row k-state-selected" data-uid="122bb914-87c2-4f0c-9351-52c1d9b84ae5" style="background-color: rgb(255, 255, 255);">
如何设置为背景色:rgb(255、255、255)?如何将其覆盖为类似棕色的背景色:#f0713a,边框颜色:#f0713a?有几种方法可以做到这一点。最简单的方法是通过CSS 修改所选行的样式
#grid tr.k-state-selected td {
background-color: #f0713a;
border-color: #f0713a
}
#grid td.k-state-selected {
background-color: #f0713a;
border-color: #f0713a
}
修改选定单元格的样式
#grid tr.k-state-selected td {
background-color: #f0713a;
border-color: #f0713a
}
#grid td.k-state-selected {
background-color: #f0713a;
border-color: #f0713a
}
在您的网格声明中,确保已设置:
selectable: "cell"
这是一个单格的
另一种方法是用剑道样式覆盖剑道样式。但这是非常庞大的 如果您希望以编程方式执行此操作,也可以通过在网格的
change
事件中获取所选元素,然后在代码中设置元素的背景来实现。如果您需要此选项,我会尝试这样做,但在我看来,将UI内容留给css,将编码留给javascript