【问题标题】:how to style kendo grid mvc using CSS如何使用 CSS 设置剑道网格 mvc 的样式
【发布时间】:2016-01-20 22:30:16
【问题描述】:

这就是我的网格

@(Html.Kendo().Grid<OPAMvc.Models.Parts>()
                        .Name("grd")
                        .Columns(columns =>
                        {
                            columns.Bound(o => o.Id).Title("Id No").Width(80).HeaderHtmlAttributes(new { style = "font-size: 8pt; font-weight: bold;" }).HtmlAttributes(new { style = "line-height: 1em;font-size: 7pt;" });
                            columns.Bound(o => o.Desc).Title("Description").Width(200).HeaderHtmlAttributes(new { style = "font-size: 8pt; font-weight: bold;" }).HtmlAttributes(new { style = "line-height: 1em;font-size: 7pt;" });
                            columns.Bound(o => o.Price).Title("Price").Width(50).Format("{0:c}").HeaderHtmlAttributes(new { style = "font-size: 8pt; font-weight: bold;" }).HtmlAttributes(new { style = "line-height: 1em;font-size: 7pt;" });
                            columns.Bound(o => o.Name).Title("Name").Width(20).HeaderHtmlAttributes(new { style = "font-size: 8pt; font-weight: bold;" }).HtmlAttributes(new { style = "line-height: 1em;font-size: 7pt;" });
                        })

我想知道是否有更好的方法来使用 CSS 设置标题样式。谢谢。

【问题讨论】:

    标签: kendo-asp.net-mvc


    【解决方案1】:

    我已经申请了一些样式Kendo grid的方法如下图,但不知道对你有没有帮助。

    用于定义剑道网格的样式属性:

    @(Html.Kendo().Grid<Model>()
      //define style properties at here
      .HtmlAttributes(new { style = "border:none; height:600px;" }) 
      //... code omitted for brevity
    )
    


    使用模板对网格的单个单元格进行样式设置: 为了使用有条件选择的操作格式化Kendo Grid 列值,您可以使用下面的示例。欲了解更多信息:How Do I Have Conditional Logic in a Column Client Template?

    <div id="grid"></div>
    
    <script> 
    function Getvalue(value) {
        // console.log(value);
        if (value && value != null && value.indexOf("A") == 0)
            return "<b style='color:red'>" + value + "</b>";
        else
            return "";
    }
    
    $(document).ready(function () {     
        $("#grid").kendoGrid({
            dataSource: localDataSource,
            columns: [
                {
                    field: "FirstName",
                    title: "First Name", template: '#=Getvalue(FirstName)#'
                }
            ],
        }); 
    });
    </script>
    

    希望这会有所帮助...

    【讨论】:

      【解决方案2】:

      单独设置网格标题的最常用方法是应用 css 规则。 试试下面的

      #grd .k-grid-header .k-header
      {
         font-size: 8pt; 
         font-weight: bold;
      }
      

      此规则将获取您的“grd”标头类并应用样式

      【讨论】:

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