【问题标题】:In asp.net MVC Telerik grid, How to change background color of selected row在 asp.net MVC Telerik 网格中,如何更改所选行的背景颜色
【发布时间】:2015-03-12 11:45:51
【问题描述】:

在 asp.net MVC Telerik 网格中,如何更改所选行的背景颜色,因为我在网格内使用 ActionLink,我的默认选择颜色是蓝色,链接颜色也是蓝色,所以当我选择任何行时链接不可见

下面是我的代码

 @(Html.Kendo().Grid<Aspectek.MBI.Entities.Products.Product>()
            .Name("Grid")
        .Columns(columns =>
        {            
            columns.Bound(e => e.SKU).Filterable(ftb => ftb.Cell(cell => cell.ShowOperators(false))).Width(120);
            columns.Bound(o => o.Barcode).Filterable(ftb => ftb.Cell(cell => cell.ShowOperators(false))).Width(120);
            columns.Bound(o => o.ProductName).Filterable(ftb => ftb.Cell(cell => cell.ShowOperators(false))).Width(120);
            columns.Bound(o => o.Category.CategoryName).Filterable(ftb => ftb.UI("CategoryFilter")).Width(120);
            columns.Bound(o => o.SubCategory.SubCategoryName).Filterable(ftb => ftb.UI("SubCategoryFilter")).Width(120);           

            columns.Bound(o => o.IsActive).Filterable(ftb => ftb.Cell(cell => cell.ShowOperators(false))).Width(120);
            columns.Template(@<text> @Html.ActionLink("Edit", "Product", new { id = item.Id, @style = "text-transform:capitalize;" }) </text>).ClientTemplate("<a href='/Products/Product/Edit/#= Id#'>View/Edit</a>").Width(100); 
            columns.Template(@<text> @Html.ActionLink("Duplicate", "Product", new { id = item.Id }) </text>).ClientTemplate("<a href='/Products/Product/CopyProduct/#= Id#'>CopyProduct</a>").Width(100);
            columns.Template(@<text> @Html.ActionLink("ExportHTML", "Product", new { id = item.Id }) </text>).ClientTemplate("<a href='/Products/Product/ExportHTML/#= Id#'>ExportHTML</a>").Width(100);
            columns.Template(@<text> @Html.ActionLink("SendEmail", "Product", new { id = item.Id }) </text>).ClientTemplate("<a href='/Products/Product/SendEmail/#= Id#'>SendEmail</a>").Width(100);
                        columns.Command(c =>
            {
                c.Custom("DeleteRecord").Text("Delete").Click("onClick");
            });
        })
.Events(ev => ev.DataBound("onDataBound"))
.ToolBar(toolBar => toolbar
.Custom()
.Text("Export To CSV")
.HtmlAttributes(new { id = "export" })
.Url(Url.Action("ProductExportToCSVFile", "Product", new { page = 1, pageSize = "20" )))
.ToolBar(tools => tools.Excel())
.Excel(excel => excel
.FileName("MBI Products Export.xlsx").Filterable(true)
.ProxyURL(Url.Action("Excel_Export_Save", "Product"))).ToolBar(tools => tools.Pdf()).Pdf(pdf => pdf
.FileName("MBI Products Export.pdf")
.ProxyURL(Url.Action("Pdf_Export_Save", "Grid")))
.Sortable()
.Pageable()
.Scrollable()
.Editable(editable => editable.Mode(GridEditMode.PopUp))
.Reorderable(reorderable => reorderable.Columns(true))
.Resizable(resizable => resizable.Columns(true))
.ClientDetailTemplateId("template")
.Selectable(selectable => selectable
.Mode(GridSelectionMode.Multiple))
.Filterable(filterable => filterable
.Extra(false)
.Operators(operators =>
.ForString(str => str.Clear()
.StartsWith("Starts with")
.Contains("Contains")
.IsEqualTo("Is equal to")
.IsNotEqualTo("Is not equal to"))))
.HtmlAttributes(new { style = "height:500px;" })
.DataSource(dataSource => dataSource.Ajax()
.PageSize(10)
.ServerOperation(false)
.Read(read => read.Action("Products_Read", "Product"))
.Model(model => model.Id(p => p.Id))
.Destroy(update => update.Action("DeleteProduct", "Product"))
))

【问题讨论】:

  • 默认颜色实际上是橙色。
  • 嗨,Pluc,实际上在我的应用程序中,颜色是蓝色的,我不知道如何更改主题,这方面有什么知识吗?
  • 您可以通过选择包含的 .css 文件来选择主题。共同点将永远存在,但第二个 .css 是主题。如果你使用“kendo.default.css”,默认的“highlight”颜色将为橙色。您可以使用主题构建器 (docs.telerik.com/kendo-ui/themebuilder) 构建自己的主题。如果您的颜色变化是全局性的,您可能需要调查一下。您也可以在运行时更改主题,但我从未研究过。

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


【解决方案1】:

我猜这是因为您选择了主题?但是您可以使用普通的旧 css 轻松地覆盖背景颜色。

此示例将选定的行颜色设置为灰色并带有白色文本

<style type="text/css">
    .k-state-selected  {
        color: #fff;
        background-color: #dcdcdc;
    }
</style>

【讨论】:

  • 嗨乔,如何在 @Html.ActionLink 中使用这个 CSS
  • @sandeepduddu 我用剑道网格将此添加到页面顶部。
  • 你能把这行代码贴在这里。我在页面顶部找不到它。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-07
  • 2014-08-01
  • 1970-01-01
  • 2011-01-25
  • 1970-01-01
相关资源
最近更新 更多