edit() API not working

edit() API not working

binexlinebinexline Posts: 27Questions: 10Answers: 0
edited July 2020 in Free community support

Does anyone know why editor.edit(row, false).set(data).submit() is not working?
data looks like this: {PKR: "Domex", SHPR: "Domex"}

My table is initialized with KeyTable.

                    keys: {
                        editor: editor,
                        clipboard: false
                    }

Here are the codes:

            editor = new $.fn.dataTable.Editor({
                ajax: "data.php",
                table: "#tableEditable",
                fields: fields
            })

                tableEditable = $('#tableEditable').DataTable({
                    ajax: "data.php",
                    columns: columns,
                    keys: {
                        editor: editor,
                        clipboard: false
                    }
                })

            navigator.clipboard.readText().then(text => {
                var cell = tableEditable.cell({ focused: true })
                if (!cell.index()) return

                var array = text.split("\t")
                var data = new Object()
                for (let index = 0; index < array.length; index++) {
                    const element = array[index];
                    cell = tableEditable.cell(cell.index().row, cell.index().column + index)
                    const column = $(tableEditable.column(cell.index().column).header()).text().replace(".", "")
                    data[column] = element
                }
                var row = tableEditable.row(cell.index().row)
                editor.edit(row, false).set(data).submit()
            })

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,213Questions: 1Answers: 10,415 Site admin
    Answer ✓

    Thanks for the code. Is there any chance of a link to a page showing the issue as well?

    It isn't immediately obvious to me why that wouldn't be working. If you console.log(data); just before your editor.edit(...) line, what does the console show?

    Are there any errors shown on the console at all? Does the Ajax request to the server go? If so, what is sent and what is returned?

    Thanks,
    Allan

  • binexlinebinexline Posts: 27Questions: 10Answers: 0

    Hi Allan,

    Never mind, I found out what the problem is... I have a column with '.' included in the name which isn't delivered to the server correctly...:)

    Thank you,
    Leanne

This discussion has been closed.