Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
50
Error when move row on client side
posted

Hi,

I am having problem in moving rows in webgrid either up or down. The error seem to be appear when I try to swap the position of the last 2 rows. The javascript error message is 'Node' is null or not an object. My Javascript code as below. Would be glad if someone can help me on this. Thanks.

function MoveRow(gridName,direction)
            {
                var oGrid = igtbl_getGridById(gridName);
                var selectedRow = oGrid.getActiveRow();

                if(direction=="up" && selectedRow.getIndex()>0)
                {
                    try
                    {
                        var toPosition = selectedRow.getIndex()-1;
                        oGrid.Rows.remove(selectedRow.getIndex());
                        oGrid.Rows.insert(selectedRow,toPosition);
                    }
                    catch(e)
                    {
                        alert(e.message);
                        return;
                    }
                }
                else if(direction=="down" && (selectedRow.getIndex()+1)< oGrid.Rows.length)
                {
                    try
                    {
                        var toPosition = selectedRow.getIndex()+1;
                        oGrid.Rows.remove(selectedRow.getIndex());
                        oGrid.Rows.insert(selectedRow,toPosition);
                    }
                    catch(e)
                    {
                        alert(e.message);
                        return;
                    }
                }
                return true;
            }

Parents
No Data
Reply Children
No Data