datatable Add row input

datatable Add row input

Escobedo97Escobedo97 Posts: 12Questions: 7Answers: 0

im using ths as an example: http://live.datatables.net/cepasoda/10/edit
how can i auto focus on the created input element after clicking on the add row button

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954
    Answer ✓

    There are two steps needed. First is to display the page the new row is added to. The apge is determined by the table sorting. Second is to find the input of the new row and use jQuery focus() to focus the input.

    To go to the page of the new row you can use the page.jumpToData() plugin or the row().show() plugin. You can find these plugins here.

    The row.add() API returns the row that was added. You can then use row().node() to get the node then find the input to focus. Updated example:
    http://live.datatables.net/cepasoda/13/edit

    Kevin

Sign In or Register to comment.