2013-03-12 70 views
1

我通過聽改變id列的值在我的網格應用到文本框的changeExtJS的 - 保持網格行選擇的同時編輯

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

回答

1

選擇該行自sync()導致了這個錯誤,我現在用的是好辦法:

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

改變後,我取消(這是幸運不可見)然後選擇。至少它有效。

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 select method

下面是一個簡單fiddle你可以玩。如果單擊「測試」按鈕,它會在索引1

+0

謝謝。我試過了,沒有工作。我仍然不知道如何讓編輯狀態恢復正常。看我的編輯。 – Patrick 2013-03-13 15:57:26