1

id我通过收听change文本字段来更改网格中列的值:

oTextfieldName.on( 'change', function( oField, strValue ) {
   oStore.getAt( 0 ).setId( strValue );
}

但是,如果setId()被调用,0则删除该行的选择。我的应用程序依赖于选定的行来保持选中状态。

如何保持选中行,同时仍编辑/更改该 id 列?


编辑:

使用时store.sync(),它会重新被选中。

但是,我的商店搞砸了:

Uncaught TypeError: Object function () { this.destroy = Ext.emptyFn; } has no method 'indexOf' ext-dev.js:1253

4

2 回答 2

2

你可以重新选择行吗?

oTextfieldName.on( 'change', function( oField, strValue ) {
   oStore.getAt( 0 ).setId( strValue );
   yourGrid.getSelectionModel().select(0);
}

您也可以执行类似的操作来禁止触发选择事件。

var suppressEvent = true;
yourGrid.getSelectionModel().select(rowIndex, null, suppressEvent);  

查看SelectionModel 选择方法的文档

这是一个你可以玩的简单小提琴。如果单击“测试”按钮,它将选择索引 1 处的行。

于 2013-03-12T23:19:08.757 回答
1

由于sync()导致了这个错误,我现在使用这种糟糕的方式:

oSelectionModel.deselect( nIndex, true );        
oSelectionModel.select( nIndex, true );

更改后,我取消选择(幸运的是不可见)然后选择。至少它有效。

于 2013-03-13T16:18:06.410 回答