About editor.create

About editor.create

f.talamini@stmingegneria.euf.talamini@stmingegneria.eu Posts: 23Questions: 11Answers: 0

Hello, i need to add rows to a datatable and it mysql database:
Using this code:
editor
.create( false )
.set( 'name', 'Test user' )
.set( 'access', 'Read only' )
.submit();
It seems I can't store my values. If I erase the set part it work perfectly!
How can I store my values?
Thank you,
Regards,
Franco.

This question has accepted answers - jump to:

Answers

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

    Can you give me a link to a page showing the issue please? That looks like it should work absolutely fine.

    Allan

  • f.talamini@stmingegneria.euf.talamini@stmingegneria.eu Posts: 23Questions: 11Answers: 0

    The demo page is: www.bollettamia.it/test/addrow.php

    There are 2 custom buttons: copy and paste. When you push copy the selection of rows is copied into an array and when you push paste the editor.create(false) is called in a each loop and then the fields in the copied row are copied into the newly created row.
    It seems the .set funcion is not member of the new row.
    The error code is:
    SCRIPT5007: Unable to get property 'set' of undefined or null reference
    dataTables.editor.min.js (56,180)

    Thank you,
    Franco

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

    Hi Franco,

    You can't really use Editor's create() method in a loop. Because the Ajax submit is async, you need to submit one, wait for it to complete and then submit another.

    So you have two options:

    1. Set up a queuing mechanism so that it will do exactly that
    2. Use the multi-row editing APIs to create multiple rows with a single Ajax call.

    Allan

  • f.talamini@stmingegneria.euf.talamini@stmingegneria.eu Posts: 23Questions: 11Answers: 0

    Thank you Allan.
    Franco

  • f.talamini@stmingegneria.euf.talamini@stmingegneria.eu Posts: 23Questions: 11Answers: 0
    edited March 2017

    I was trying to use the multi-row editing APIs but I still have the same problem: the create and submit methods work properly while the multiSet doesn't: it seems editor.multiSet doesn't exist!

    the sample code is on http://bollettamia.it/test/addrow.php

    Thank you,
    Franco

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

    The error is occurring because there is no field by the given name. For example you have K: c3, but there is no field called K in the Editor instance. It is called Servizi.K. The object property names need to match those used in the Editor configuration.

    Allan

This discussion has been closed.