Row is not visible in grid viewable area when row in webgrid moved up and down

5 replies. Last post: January 21, 2013 1:31 AM by psr
Tags :
  • New Discussion
  • New Question
  • New Product Feedback
psr Member

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

 

 

 

 

 

All times are GMT -5. The time now is 7:05 AM.
Previous Next