Editor - Programatically add an (incomplete) row

Editor - Programatically add an (incomplete) row

guidolsguidols Posts: 27Questions: 10Answers: 1

I have an Editor table with a fairly complicated model, but where each field is not mandatory (i.e. I can click on the "New" button, and then add an "empty" row without filling any field).

I'm now trying to add a new row programatically.

I tried something like:

window.editorTable.row.add({"Main": { "Id": 999, }}).draw();

but it seems that then other fields are missing (error is: Requested unknown parameter Main.Status).

I then tried to add all the fields to the table:

window.editorTable.row.add({"Main": {
    "Id": 999, 
    "Status": "xxx"
    // all other fields here

and in this case I don't get anymore any error, but the row is just not added to the table.

I also tried to add a jQuery object like this:

var jRow = $("<tr>").append("<td>1</td>", "<td>2</td>");

but still no success..

How can I programatically add a row to my table?

Should I provide all the columns data, or can I just add a row with information in it (and let the server do the validation)?


This question has an accepted answers - jump to answer


  • colincolin Posts: 14,458Questions: 1Answers: 2,464
    Answer ✓

    row.add() will only add a row to the table in the DOM - if you are using Editor, you would want to use create(), so you may be not doing what you want to be doing.

    Could you give some additional context, please. Are you using Editor on this table? Can you post both the Editor and DataTable initialisation code, please.


  • guidolsguidols Posts: 27Questions: 10Answers: 1

    Oh, thanks! I was using the wrong API :s

    Solved using:

    editor.create(false).set('Main.Id', 954).submit();


Sign In or Register to comment.