Hi
I have a grid that is navigated with the arrow keys
I need to define the first and the last column as the limits, this means that when I reach through the keys the last column, and then I press right arrow again, I don't want to jump to the first column, and on the other hand, when I reach the first column, I don't want to jump to the last one. NAVIGATION DEPENDENT NONLINEAR DEPTH SCALING Ingo Feldmann, Ulrich :: File Format: PDF/Adobe AcrobatBecause usually dispar-. ities are estimated within the pixel sampling grid the image. resolution and the camera distance define the positions of http://iphome.hhi.de/feldmann/pdfs/FGK03.pdfHOME |
Do you know how could I do this?
To clarify: You are using an Ext.grid.CellSelectionModel and when you press the left/right keys you do not want to go the previous/next row when you go past the first/last cell?
->Yes, this is correct.
This behavior is implemented in GridPanel's walkCells private method. I think you will have to override this method to get what you are looking for.
Hooking onto the beforecellselect event will not work because the event does not provide you any information about the previously selected cell.
->Well currently i hook via the "keypress" method. Here we have all necessary information. But main problem is that we are not able to stop the cursor at the end of the row.
Can you give me please a short example how to overwrite the walkCells private method?
Thanks for your reply!
I modified it a little bit, because the user could hide some columns, therefore I need to get the first and the last not hidden columns.
Ext.override(Ext.grid.GridPanel, {
walkCells : function(row, col, step, fn, scope){
var cm = this.colModel, clen = cm.getColumnCount();
var ds = this.store, rlen = ds.getCount(), first = true;
var firstColumnIndex,lastColumnIndex;
for(i=0;i<=clen-1;i++){
if(cm.getColumnById(cm.getDataIndex(i)).hidden!=tr ue && firstColumnIndex==undefined){
firstColumnIndex=cm.getIndexById(cm.getColumnId(i) );//here we get the first not hidden column
}
if(cm.getColumnById(cm.getDataIndex(i)).hidden!=tr ue){
lastColumnIndex=cm.getIndexById(cm.getColumnId(i)) ;//here we get the last not hidden column
}
}
lastColumnIndex=lastColumnIndex+1;
if(step < 0){//when the user press left arrow
if(col < firstColumnIndex){
//row--;
//first = false;
return [row, firstColumnIndex];
}
while(row >= 0){
if(!first){
col = clen-1;
}
first = false;
while(col >= 0){
if(fn.call(scope this, row, col, cm) === true){
return [row, col];
}
col--;
}
row--;
}
} else {
if(col >= lastColumnIndex){
//row++;
//first = false;
return [row, col-1];
}
while(row < rlen){
if(!first){
col = 0;
}
first = false;
while(col < clen){
if(fn.call(scope this, row, col, cm) === true){
return [row, col];
}
col++;
}
row++;
}
}
return null;
}
});
Ext.override(Ext.grid.GridPanel, {
walkCells : function(row, col, step, fn, scope){
var cm = this.colModel, clen = cm.getColumnCount();
var ds = this.store, rlen = ds.getCount(), first = true;
if(step < 0){
if(col < 0){
//row--;
//first = false;
return [row, 0];
}
while(row >= 0){
if(!first){
col = clen-1;
}
first = false;
while(col >= 0){
if(fn.call(scope this, row, col, cm) === true){
return [row, col];
}
col--;
}
row--;
}
} else {
if(col >= clen){
//row++;
//first = false;
return [row, col-1];
}
while(row < rlen){
if(!first){
col = 0;
}
first = false;
while(col < clen){
if(fn.call(scope this, row, col, cm) === true){
return [row, col];
}
col++;
}
row++;
}
}
return null;
}
});
To clarify: You are using an Ext.grid.CellSelectionModel and when you press the left/right keys you do not want to go the previous/next row when you go past the first/last cell?
This behavior is implemented in GridPanel's walkCells private method. I think you will have to override this method to get what you are looking for.
Hooking onto the beforecellselect event will not work because the event does not provide you any information about the previously selected cell.
Where's The Advantage In Windows Genuine Advantage?
Stocks Bounce After S&P Joins Bear Market
|