簡體   English   中英

ExtJs - 在編輯時保持選中網格行

[英]ExtJs - keep grid row selected while edit

我通過監聽文本字段的changechange網格中id列的值:

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

你能重新選擇一行嗎?

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處的行。

由於sync()導致了這個錯誤,我現在使用那種糟糕的方式:

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

更改后,我取消選擇(幸運地看不見),然后選擇。 至少它有效。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM