【问题标题】:Sort comboboxes of a gridpanel column对网格面板列的组合框进行排序
【发布时间】:2012-04-04 21:28:44
【问题描述】:

在网格面板的 a 列中,我使用组合框作为编辑器和渲染器来显示值:

editor: {
    xtype: 'combobox',
    alias: 'bienTypeCombobox',
    store: 'BienTypesStore',
    valueField: 'id_bien_type',
    displayField: 'nom',
    autoHeight: true,
    editable: false,
    autoSelect: true,
    allowBlank: false
},
renderer: function (value, metaData, record, rowIndex, colIndex, store, view) {
    var display = '';
    Ext.data.StoreManager.get("BienTypesStore").each(

    function (rec) {
        if (rec.get('id_bien_type') === value) {
            display = rec.get('nom');
            return false;
        }
    });
    return display;
}

因此,当单元格被编辑时,组合框被显示,当单元格未被编辑时,该组合框的 displayField 被显示。

我的问题是,现在,当我单击该列的标题时,行按组合框的 valueField 排序。

我想让用户能够通过组合框的显示字段对该列进行排序。

请帮忙,谢谢

【问题讨论】:

  • 除了指定displayField和valueField,你怎么还用渲染器?
  • @ddrmaxgt37 - 没关系。他们是独立的

标签: sorting extjs combobox gridpanel


【解决方案1】:

我认为这没有简单的解决方案。我能想到的唯一一种方法是:

  • 在您的模型中创建一个虚拟字段(基本上带有显示字段)。为这个虚拟字段创建转换函数,这样当它被设置时,真实值字段就会被更新。

  • 在网格中使用此虚拟字段,无需额外渲染

  • 对该字段使用编辑器,其中 valueField 和 displayField 都指向该字段。

【讨论】:

    猜你喜欢
    • 2023-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-08
    相关资源
    最近更新 更多