cell().focus() partially work

cell().focus() partially work

jfrjfr Posts: 71Questions: 24Answers: 0

Hi
I have an inline table editing
I do a select on the last row and then focus the Field_4 in footerCallback.

oTable.row("#row_999").select();
oTable.cell("#row_999",":eq(4)").focus();

This row is a dummy line send by the server for new entry.

It is selected, "#row_999", and the cell 4 is highlighted.
An entry box is showed but the cursor is no where to be found.
I added

  editor.field("Field_4").input().on('focus', function () {
    jQuery(this).select();
    console.log("Field_4 focus"); 
  });

witch will fired only if I click on the field

Do I have something else to do to have the cursor in the inner-editor ready for input ?

Thanks

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    cell().focus() doesn't active the editing itself - you'd need to call the inline() method to activate inline editing. The cell().focus() method is specific to KeyTable and just sets its focus.

    Allan

  • jfrjfr Posts: 71Questions: 24Answers: 0

    Hi Allan
    I have the following in the set-up

     oTable.DataTable({
    +++
    "footerCallback": function (tfoot, data, start, end, display) {
       if (end) {
          oTable.row("#row_999").select();
         oTable.cell("#row_999",":eq(4)").focus();
       }
    },
    "keys": {
       "editor": editor,
       "columns": [4,6,7,8,9,10] ,
        "keys": [ "\t".charCodeAt(0) ],
        "editorKeys": "tab-only"
     },
    +++
    

    And the following code for activation

    oTable.on("key-focus", function ( e, datatable, cell ) {
       editor.inline( cell.index(), {
          onBlur: 'submit'
        });
    });
    

    I based my edit on the Editor example Tab between columns

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Could you give me a link to the page please? I'll try to put a demo together locally in the next few days, but I suspect the keys option might be causing part of the issue. It won't activate editing like that.

    Allan

This discussion has been closed.