PDA

View Full Version : [SOLVED] Cosmetic problem for get index ID of selected row



vaucer
8 Apr 2010, 6:02 AM
Hello,

I encounter a problem for retrieve the focus on my grid after reload.

I founded on the forum this solution for hold the position of my scroll:


Ext.override(Ext.grid.GridView, {
holdPosition: false,
onLoad : function(){
if (!this.holdPosition) this.scrollToTop();
this.holdPosition = false
}
});

Grid.getView().holdPosition = true;
But i would like to set the focus on my selected row.

I tried many solutions on this forum but i don't found.

I believe im able to get the id of my row like this, but it's never the good row selected:



Grid.focus();
sR = Grid.getSelectionModel().getSelected();
Grid.getSelectionModel().selectRow(parseInt(sR.id);
Grid.getView().focusRow(parseInt(sR.id));thx you very much for your help.

Vaucer

steffenk
8 Apr 2010, 7:54 AM
getSelected() returns a record. Did you ever debugged the record?
For selection you need the row index, not the id of the record.

vaucer
8 Apr 2010, 10:47 AM
First thx you for you answer.

Finally i used this solution:


Ext.grid.RowSelectionModel.override ({
getSelectedIndex : function(){
return this.grid.store.indexOf( this.selections.itemAt(0) );
}
});

then:

Grid.getSelectionModel().getSelectedIndex();

It's solved.

Vaucer