ExtJS 重复列 Headers 网格中的冲突

ExtJS Duplicate Column Headers Conflict in Grid

我想要一个允许重复列名但包含不同数据的网格。显然这会导致冲突,具有重复名称的列只是从第一列复制数据并移动其他数据。

这就是我的意思。我有一个列 "FirstName",我想将其重命名为 "Login":

我重命名了它,但是 "Login" 已经存在并且发生了这种情况:

我的商店是这样动态添加到网格中的:

var columnNames = ["RecordID", "RowDateModified", "Login", "ActionType", "DateModified", "RawDataSetSyncDiscardedType", "ID", "FirstName", "LastName", "Email", "Gender"]
var myData = [["3000010032", "2017-04-25 09:11:47.2600000", "Administrator", "I", "2017-04-25 09:11:47.3570000", "COMMITTED", "3", "Lawrence", "Stone", "lstone2@toplist.cz", "Male"],["3000010033", "2017-04-25 09:11:47.2600000", "Administrator", "I", "2017-04-25 09:11:47.3570000", "COMMITTED", "2", "Karen", "Dean", "kdean1@ovh.net", "Female"],["3000010034", "2017-04-25 09:11:47.2600000", "Administrator", "I", "2017-04-25 09:11:47.3570000", "COMMITTED", "4", "Marie", "Carter", "mcarter3@jiathis.com", "Female"],["3000010035", "2017-04-25 09:11:47.2600000", "Administrator", "I", "2017-04-25 09:11:47.3570000", "COMMITTED", "6", "Lawrence", "Richardson", "lrichardson5@ovh.net", "Male"]]

dataStore = Ext.create('Ext.data.ArrayStore', {
fields: columnNames,
data: myData
});

for (var i = 0; i < columnNames.length; i++) {
columnsArr.push({
    text: columnNames[i],
    sortable: true,
    forceFit: true,
    minWidth: 150,
    dataIndex: columnNames[i]
});
}

grid.reconfigure(dataStore, columnsArr);

编辑:columnNamesmyData 是动态生成的。当我重命名列时,重命名函数 returns 不同于 columnNames 数组。

我怀疑这是 ExtJS 的问题,但不能在 table 中使用重复名称是没有意义的。

我的问题是我是不是做错了什么(比如遗漏了 属性)或者我应该采用一些变通方法来解决这个问题?

我正在使用 ExtJS 4.0.7

ExtJS 使用 dataIndex 字段将您的数据绑定到您的列。但是您为两列设置了相同的 dataIndex。这就是为什么你的两列中有相同的数据。

只需使用一个 array 设置列的 text 和另一个设置 dataIndex

var columnNames = ["RecordID", "RowDateModified", "Login", "ActionType", "DateModified", "RawDataSetSyncDiscardedType", "ID", "Login", "LastName", "Email", "Gender"];
var columnDataIndexes = ["RecordID", "RowDateModified", "Login", "ActionType", "DateModified", "RawDataSetSyncDiscardedType", "ID", "FirstName", "LastName", "Email", "Gender"]
var myData = [["3000010032", "2017-04-25 09:11:47.2600000", "Administrator", "I", "2017-04-25 09:11:47.3570000", "COMMITTED", "3", "Lawrence", "Stone", "lstone2@toplist.cz", "Male"],["3000010033", "2017-04-25 09:11:47.2600000", "Administrator", "I", "2017-04-25 09:11:47.3570000", "COMMITTED", "2", "Karen", "Dean", "kdean1@ovh.net", "Female"],["3000010034", "2017-04-25 09:11:47.2600000", "Administrator", "I", "2017-04-25 09:11:47.3570000", "COMMITTED", "4", "Marie", "Carter", "mcarter3@jiathis.com", "Female"],["3000010035", "2017-04-25 09:11:47.2600000", "Administrator", "I", "2017-04-25 09:11:47.3570000", "COMMITTED", "6", "Lawrence", "Richardson", "lrichardson5@ovh.net", "Male"]]

dataStore = Ext.create('Ext.data.ArrayStore', {
fields: columnDataIndexes,
data: myData
});

for (var i = 0; i < columnNames.length; i++) {
columnsArr.push({
    text: columnNames[i], // <<== Column names array
    sortable: true,
    forceFit: true,
    minWidth: 150,
    dataIndex: columnDataIndexes[i] // <<== Different array here (dataIndexes)
});
}

grid.reconfigure(dataStore, columnsArr);