【问题标题】:how to set style to grid in extjs如何在extjs中将样式设置为网格
【发布时间】:2010-03-09 08:29:13
【问题描述】:

如何将样式设置为网格以显示字体系列 我是这样的 style: {'font-family': 'Brush Script MT', “字体粗细”:“粗体”
} 但结果并没有显示出来。

我也在尝试

style:'font-family:Brush Script MT; 字体大小:300px', 但它也没有根据它显示结果.. 你能告诉我为什么吗?

【问题讨论】:

    标签: coding-style extjs grid


    【解决方案1】:

    我不是 ExtJs 专家,但一种方法是在 GridPanel 中使用 getRowClass 来定义一个返回 css 类的函数。

    类似

    var grid = new Ext.grid.GridPanel({
        store:my_store,
        view: new Ext.grid.GridView({
            //forceFit:false,
            enableRowBody:true,
            ignoreAdd: true,
            deferEmptyText: false,
            emptyText: 'No Record found.',
              getRowClass: function(record, rowIndex, rp, ds){ // rp = rowParams
                    if(record.get('f_severity') == 'Critical')
                    {
                        return 'x-grid3-row red-class';
                    }
                      }
            }),
            bbar:pagingBar,
            plugins: filters,
    ....
    

    在本例中,“red-class”是一个自定义 CSS 类。

    【讨论】:

    • 它不工作不会给出任何错误但也不会给出结果
    • 这是基于业务逻辑在行级别覆盖默认样式。这与设置默认网格样式无关。
    【解决方案2】:

    字体样式是在表格单元格 (td) 级别设置的,因此您还必须在此处覆盖它们。将此添加到您的样式表中(在 Ext JS 样式表之后):

    .x-grid3-row td {
        font-family: 'Brush Script MT';
        font-weight: bold;
    }
    

    顺便说一句,这基本上是您的other question 的副本。无需多次询问。

    【讨论】:

    • 这回答了你的问题吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-04
    • 2013-05-19
    • 1970-01-01
    • 1970-01-01
    • 2011-07-19
    • 1970-01-01
    • 2016-12-08
    相关资源
    最近更新 更多