:: Forum >>

Is there a way to set focus on the first row automatically??

I have used the grid on one of my applications and frankly i think that the grid is amazing.

I would like to know if it is possible such that when my page loads, the focus is automatically set to the first row.

Any help is most welcome.
Roger Mutangadura
Wednesday, November 30, 2005
see in the example quickref/grid.htm, the line:

obj.setCurrentRow(1);
Will
Wednesday, November 30, 2005
This didn't work for me ...
obj.setCurrentRow(1);

That appears to scroll the grid.


However, to select the first row I used...
obj.setSelectedRows([0]);
Rob Francis
Wednesday, November 30, 2005
"obj.setSelectedRows([0]);" only highlight not focus. The following 2 lines will do highlighting and focusing to first row.

obj.setSelectedRows([0]);
aw50.focus();
Qing
Friday, March 3, 2006
The grid name change, so the above code "aw5o" cause error, use these to replace the code above:
<CODE class=aw-code-block>
try{obj.setSelectedRows([0]);}catch(e){;}
gGirdId = obj.getId();
try{setTimeout("document.getElementById(gGirdId).focus();",500);}catch(e){;}
</CODE>
Qing
Friday, March 3, 2006
I mean:
try{obj.setSelectedRows([0]);}catch(e){;}
gGirdId = obj.getId();
try{setTimeout("document.getElementById(gGirdId).focus();",500);}catch(e){;}
Qing
Friday, March 3, 2006
This does not work!! If I select ANY row, the first row never is displayed. Even setCurrentRow does not work! This a bug!!
Karl
Friday, September 8, 2006
This is very much effective and helpfull

thanx.
Maksud Belim
Wednesday, September 13, 2006
hi

and if i want to start editing, at the moment the row is just focus

Thanks in advance
Nuno Silva
Thursday, September 28, 2006
This worked for me:

grid.setSelectionMode("single-row");
grid.setSelectedRows([0]);
This need to be added in the code before:
grid.setCellText(tableContent);
Otherwice the first row is not shown in the grid

Linda
Wednesday, October 25, 2006
this worked for me:

insert this block before the call to grid.setcelltext:

grid.setSelectionMode("single-row");
grid.setSelectedRows([0]);

Then I had to call the grid.setSelectedRows([0]); after the grid.setcelltext(..) call.
This was the only way to get this working without hiding the first row in the grid.
Linda
Wednesday, October 25, 2006
I worked on this for a long time in my project.
I had to call this code after obj.setCellData(..) and obj.setRowCount(..) and any cell formating.
Some of the obj.refresh() may be redundant but it worked for me.
Basically I set focus to the second row and bac to the first.

obj.clearSelectionModel();
obj.refresh();

obj.setSelectedRows([1]);
obj.setCellSelected();

obj.refresh();
obj.setSelectedRows([0]);

obj.refresh();
Colin P.
Wednesday, October 25, 2006
Hi,
this worked for me:

...
obj.setSelectionMode("single-row");
obj.setSelectedRows([0]);
obj.setSelectedRows([0]);
...
Luca
Thursday, December 7, 2006

This topic is archived.


Back to support forum

Forum search