Unable to automatically determine field when column renders custom buttons only

Unable to automatically determine field when column renders custom buttons only

Red SniperRed Sniper Posts: 52Questions: 11Answers: 0

Link to test case:
http://live.datatables.net/hovopoce/1/edit

Error messages shown:
Uncaught Unable to automatically determine field from source. Please specify the field name. For more information, please refer to https://datatables.net/tn/11

Description of problem:
When I move from cell to cell pressing the tab key, as I reach the last column (which renders only 2 buttons, no data reading from data array) , the error above appears. I ve tried removing the obj of that column from the editor.fields , but didn't work.
This error prevents the 'click' events (defined in the datatable) to be assigned to the buttons.

How can i render custom buttons in a columns that isn't related to any data and keep the tab feature to move from 1 cell to another?
How can i add 1 new empty line when i press tab on the last cell of the last row (excluding the column with btns)?

Thanks in advance for the help!

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    I'm not seeing the problem, tabbing for me takes me out of the table, but a couple of suggestions.

    First. with Editor, you only need to defined fields for those you wish to edit. So in your case, you wouldn't need that fourth one defined.

    Also, you can tell KeyTable to not tab into that final column with keys.columns, something like this:

                keys: {
                    keys: [ 9 ],
                    editor: modelObj.editor,
                    editOnFocus: true,
                    columns: ':not(:last-child)'
                },
    

    Hopefully that'll do the trick, please let us know if any problems persist.

    Colin

  • Red SniperRed Sniper Posts: 52Questions: 11Answers: 0

    Hi Colin,
    many thanks for the suggestions. I didn't know I had to specify only the columns I wanted to be editable.
    Adding the columns option in the keys obj solved the problem.

    Is there a way to add a new empty line when i "tab" out of the last cell of the last row ?
    I think I have to use the closed event ? (correct me if I am wrong)

    Thanks again!

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Glad all sorted. For the empty line, it would be best to do that in the submitComplete. This example is creating an empty record, so you may be able to pinch ideas from there,

    Colin

  • Red SniperRed Sniper Posts: 52Questions: 11Answers: 0

    Thank you very much again!
    I'll work on it , and in case let you know if I 'll find any trouble

Sign In or Register to comment.