ExtJS:如何为initComponent中的Grid列设置默认值? [英] ExtJS: How to set defaults for Grid columns within initComponent?

查看:198
本文介绍了ExtJS:如何为initComponent中的Grid列设置默认值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如下所示,我正在使用 Ext.Array.merge 渲染<$ c中的 $ c> initComponent 。

as you notice below, I'm using Ext.Array.merge to render columns within initComponent.

我尝试设置' flex 属性在 initComponent 中作为默认值。
如何实现这种安排?

I'm try to set columns' flex property as default in initComponent. How can I achieve to this arrangement?

initComponent: function () {
        var me = this;
        Ext.on('resize', function () { me.height = window.innerHeight - App.MAIN_FOOTER_HEIGHT - App.MAIN_HEADER_HEIGHT - 100 });

        me.createGridMenu();

        me.columns = Ext.Array.merge(me.getListColsStart(), me.getListCols(), me.getListColsEnd());

        //I need to set through here. Any solution such as setDefaults or dot notation to fetch defaults of columns?

        me.callParent(arguments);
    },

,这是替代功能之一

getListCols: function () {
        return [];
    },

更新:
相关的第二个问题移至为嵌套对象的面板项设置默认值。仅供参考。

推荐答案

此处摘录自API文档,摘录自 文档(它还包含与您的问题有关的示例):

Here is an excerpt from the API Docs, from the columns documentation (it also contains an example related to your question):


这也可以是
Ext.grid的配置对象。 header.Container,必要时可以覆盖某些默认的
配置。例如,特殊布局可能被
覆盖以使用更简单的布局,或者可以设置所有列共享的默认值

因此,在您的情况下,这是将 flex 设置为所有列的默认配置的方法:

So, in your case, here is how you can setup flex as a default config for all columns:

me.columns = {
    items: Ext.Array.merge(
        me.getListColsStart(),
        me.getListCols(),
        me.getListColsEnd()
    ),
    defaults: {
        flex: 1
    }
}

编辑
如果 flex 属性必须仅应用于列的子集,一种实现方法是通过应用数组地图函数位于所需的子集上:

EDIT If the flex property must be applied only to a subset of columns, one way to achieve this is by applying the array map function on the needed subset:

me.columns = Ext.Array.merge(
    me.getListColsStart(),
    Ext.Array.map(me.getListCols(), function(listColConfig) {
        listColConfig.flex = 1;
        return listColConfig;
    }),
    me.getListColsEnd()
)

这篇关于ExtJS:如何为initComponent中的Grid列设置默认值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆