【问题标题】:Adding several styles to Kendo grid button为剑道网格按钮添加几种样式
【发布时间】:2015-10-06 11:03:52
【问题描述】:

我想添加图标并更改剑道网格按钮的大小。引擎是剃须刀,这里是代码:

 @(Html.Kendo().Grid<WEB02.ConfigurationModel.TestGrid>()
.Name("grid")
.Columns(columns =>
{

    columns.Bound(o => o.Name).Width(110);
    columns.Bound(o => o.Type).Width(130);
    columns.Command(command => {command.Destroy();

    command.Custom("higher Order").Click("showDetails");
    command.Custom("AnotherCommand").Text("   ").HtmlAttributes(new { style = "background:url(/Images/Configuration/Up.png) left no-repeat" });

     });
})
.Sortable()
.Scrollable(scrollable => scrollable.Virtual(true))
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
    .Ajax()
    .Model(model => model.Id(p => p.Name))
    .PageSize(100)
    .Read(read => read.Action("ActivityGrid", "Configuration"))
    .Destroy("TestDelete", "Configuration")
    .Events(events => events.Sync("sync_handler"))       
    )


    .Pageable(pageable => pageable
        .Refresh(true))

)

我只能使用 HtmlAttributes 向此按钮添加一个样式条件。但我想添加更多,因为我也想更改按钮的大小。每当我添加任何东西时,电网故障! 有什么建议吗?

【问题讨论】:

    标签: asp.net-mvc-4 kendo-grid razorengine


    【解决方案1】:

    你有几个其他的选择,而不是这样:

    • 添加类而不是添加样式,然后为该类添加 CSS
    • 使用模板列 .ClientTemplate("一些文字")

    【讨论】:

      【解决方案2】:

      您可以使用 html HtmlAttributes 添加多个样式。

       @(Html.Kendo().Grid<TelerikMvcApp1.Models.PersonViweModel>()
       .Name("PersonList")
       .Columns(col =>
       {
       col.Bound(c => c.FirstName).Width(120);
       col.Bound(c => c.LastName).Width(120);
       col.Bound(c => c.Country).Width(120);
       col.Command(c =>
       {
       c.Edit().HtmlAttributes(new { Style = "background-color:cornflowerblue; color:White" 
       });
       c.Destroy();
       }).Title("Action");
       })
      
       .ToolBar(t => t.Create())
       .DataSource(source => source
       .Ajax()
       .Model(m => m.Id(e => e.Id))
       .Create("Create", "Home")
       .Update(u => u.Action("Update", "Home"))
       .Destroy("Delete", "Home")
       .PageSize(2)
       .Read(Read => Read.Action("Read", "Home"))
       )
       .Pageable()
       .Groupable()
       .Sortable()
       .Editable()
       .Filterable()
      .Width(600)
       )
      </div>
      

      【讨论】:

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