iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Hi,
I have a grid which containes 20 records but user can see 10 records (no paging used), so a vertical bar will appear for the grid to scorll through grid columns. thats fine.
I have two buttons "move up" and "move down" when user selects any row and clicks up/down button then the selected row posistion should move up/down correspondingly. This functionaly also working fine for me but the problem is...
when the user selects middle row in the viewable area of the grid (grid show 10 records. think that user scrolled to see 4 to 14 records.) and clicks on up/down button the selected row will move to the top of the grid and starts moving up/down. I want it to move from the same position.
these are the javascript functions for move up/down
function MoveUp() { var grid = ISGetObject("webgrid1"); var gridTable = grid.RootTable.GetElement(WG40.BODY, WG40.HTMLTABLE); var selObj = grid.GetSelectedObject(); if (selObj == null) { alert('Select a row to do the promote operation.'); return false; } var obj = grid.GetSelectedObject(); var rowEle = obj.GetRowElement(); var index = rowEle.rowIndex; try { gridTable.moveRow(index, index - 1); document.getElementById("hidCustomOrder").value = "yes"; var oRowEl = grid.RootTable.GetElement(WG40.BODY, WG40.HTMLDIV); if (oRowEl != 'undefined') { oRowEl.scrollTop = rowEle.offsetTop; } } catch (err) { } } function MoveDown() { var grid = ISGetObject("webgrid1"); var gridTable = grid.RootTable.GetElement(WG40.BODY, WG40.HTMLTABLE); var selObj = grid.GetSelectedObject(); if (selObj == null) { alert('Select a row to do the demote operation.'); return false; } var obj = grid.GetSelectedObject(); var rowEle = obj.GetRowElement(); var index = rowEle.rowIndex; var totalRows = grid.TotalRows; try { // when it reached to end of the row, make it first row selected if (index == totalRows-1) { gridTable.moveRow(index, 0); document.getElementById("hidCustomOrder").value = "yes"; } else { gridTable.moveRow(index, index + 1); document.getElementById("hidCustomOrder").value = "yes"; } var oRowEl = grid.RootTable.GetElement(WG40.BODY, WG40.HTMLDIV); if (oRowEl != 'undefined') { oRowEl.scrollTop = rowEle.offsetTop; } } catch (err) { } }
help me how to show the row in grid view area when row moved upo/down
Hello,
So, you mean it would not automatically scrollback to the row that you wanted to move, correct?
I have modified my code. No matter you scroll into the area you could not see your current selected row, it will scroll back to the selected row position after you clicked up or down button. Hope this helps.
function Down() { var grid = ISGetObject("WebGrid1"); index = grid.GetSelectedObject().rowIndex; var gridTable = grid.RootTable.GetElement(WG40.BODY, WG40.HTMLTABLE); if (index != grid.TotalRows - 1) gridTable.moveRow(index, index + 1); grid.GetSelectedObject().ToRowObject().Select(); } function Up() { var grid = ISGetObject("WebGrid1"); index = grid.GetSelectedObject().rowIndex; var gridTable = grid.RootTable.GetElement(WG40.BODY, WG40.HTMLTABLE); if (index != 0) gridTable.moveRow(index, index - 1); grid.GetSelectedObject().ToRowObject().Select(); }
Regards,Handy
I am not sure why it moved into the top of grid. It seems it is missing some logic. Please see my code.
It only moves row based on selected row/object. I also found no problem when scrolling and move from middle.
function Down() { var grid = ISGetObject("WebGrid1"); var index = grid.GetSelectedObject().ToRowObject().Position; var gridTable = grid.RootTable.GetElement(WG40.BODY, WG40.HTMLTABLE); if (index != grid.TotalRows - 1) gridTable.moveRow(index, index + 1); } function Up() { var grid = ISGetObject("WebGrid1"); var index = grid.GetSelectedObject().ToRowObject().Position; var gridTable = grid.RootTable.GetElement(WG40.BODY, WG40.HTMLTABLE); if (index != 0) gridTable.moveRow(index, index - 1); }
Hi surya,
Thanks for the reply but your code is not working.
var index = grid.GetSelectedObject().ToRowObject().Position;
The index value is always same because of that same two columns are interchanging their position again and again.
Could you give some working solution.
Thanks
Hi Surya,
If I use this code to get index
var index = grid.GetSelectedObject().GetRowElement().rowIndex;
the row moving down/up correctly but the problem is, if I keep clicking the down/up button the selected row will move behind the grid viewable area, the verticle scroll not automatically scroll to show the selected row.
How to make sure the moved row always visible in grid viewable area after moving up/down?
Thanks surya,
It solved the issue
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname