|
Rank: Member Groups: Member
Joined: 3/9/2013 Posts: 16
|
Hello...I have created an Add button with client side JS on a form to bring focus to the new row. My grid has about 300 rows and no paging - so scrollbars show up. I used the following javascript to bring focus to the new row:
Code: JavaScript
function add_button(){
var grid = eo_GetObject("Grid1");
var index = grid.getItemCount();
var item = grid.getItem(index);
grid.selectCell(index, 4);
item.ensureVisible();
}
This code does work somewhat...however...after it scrolls down to the item it then scrolls back up the grid for several rows so the new row is no longer visible. My question: is there a way to keep the focus on the new row that I'm missing? This code does select the cell but it doesn't stay in edit mode and then scrolls away. Thank You!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi, Your code looks fine. You may want to try put the cell into edit mode and see if it works. You can call this method to put the Cell into edit mode: http://www.essentialobjects.com/doc/1/jsdoc.public.grid.editcell.aspxThanks!
|
|
Rank: Member Groups: Member
Joined: 3/9/2013 Posts: 16
|
Thanks! That works to put the cell in edit mode. I changed the code a bit. But no matter what I change it to the grid scrolls all the way back up to the top row after I hit the add button.
function add_button(){ var grid = eo_GetObject("Grid1"); var item = grid.addItem(); var index = item.getIndex(); setTimeout(function () { grid.editCell(index, 4); item.ensureVisible(); }, 200); }
I used the above code to set a timeout and I can see that it is actually putting the cell in edit mode and scrolling down to it but then after the delay it still scrolls all the way back to the top. I have put a break point on all my client side functions and this is the only one being called. When I step through the code it goes through some dynamic script from the grid after the button has been pushed. Is there anything you can think of that could cause this behavior?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
We tested your code and it works fine. So it must have something to do with other code in your page. You can try to isolate the problem into a test page and then post the full test page here. Once we have that we will try to run it here and see what we can find.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 3/9/2013 Posts: 16
|
In creating a test page, I have found the issue! So sorry to have taken your time. My button was an asp button so it was runat="server" which was causing postback. I changed the button to HTML input and all is working just as it should now. Thank you for your help!
|
|