【问题标题】:kendo grid rows are rendered with default style剑道网格行以默认样式呈现
【发布时间】:2014-05-21 00:49:04
【问题描述】:

我的网格是

                      @(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")))       
    )

当我们选择一行时使用剑道网格,该行默认以棕色突出显示。单击行时无法获得默认颜色。在客户端它呈现为

       <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?

【问题讨论】:

    标签: kendo-ui kendo-grid kendo-asp.net-mvc


    【解决方案1】:

    有几种方法可以做到这一点。最简单的方法是通过 CSS

    修改选定行的样式

    #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"
    

    这是单个单元格的demo


    另一种方法是使用themebuilder 覆盖剑道样式。但这非常笨重。

    如果您想以编程方式执行此操作,也可以通过在网格的change 事件中获取所选元素,然后在代码中设置元素的背景。如果您需要此选项,我将尝试执行此操作,但按照我的看法,将 UI 内容留给 css,将编码留给 javascript。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-13
      相关资源
      最近更新 更多