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
490
igtbl_addNew method
posted

Hello,

 I am having a ultra webgrid (Version=7.2.20072.61) with AllowAddNewDefault="Yes" and the AddNewRowDefault set as visible. This grid is having 7 columns and when the page loads the gris is empty (i.e. it doesn't have any records).

My requirement is that when the users finishes inserting data in 4th column and hits "Enter Key" a new row should get created and focus should shift to the first cell of this new row. This operation should happen on the client-side.

For this I have used the AfterExitEditMode client-side event and when this event is called for the 4th column I am calling the igtbl_addNew(gridName,0) function to added a new row to the grid. But for some reason after calling this function, two new rows get added to the grid one before the current row and one after the current row. I just want the row to be added after the current row. How can I fix this Issue?

Also, I am not sure how I can set the focus on to the first cell of the new row.

Thanks,
Rajiv

 

Parents
No Data
Reply
  • 7694
    posted

     Hello,


    You can use the KeyDownHandler of ClientSideEvents and use the JS function to add new row and get focus on cell with methods scrollToView and activate. Plase taka e look at the code below:

    <ClientSideEvents KeyDownHandler="Action" />


      <script type="text/javascript">
            function Action(gridID, cellID, key) {
                if (key == 13) {
                    var grid = igtbl_getGridById(gridID);
                    igtbl_addNew(gridID, 0)
                    var getNewCell = "UltraWebGrid1_rc_" + (grid.Rows.length - 1) + "_0";
                    var cell = igtbl_getCellById(getNewCell);

                    cell.activate(true);
                    cell.scrollToView(true);

                    //to do some manipulation with the cell

                }
                return true;
            }
        
        </script>

    Hope this helps.

Children