datatable with HTML table : how to save the content ?

datatable with HTML table : how to save the content ?

x14841003x14841003 Posts: 33Questions: 9Answers: 0

Hello,

Sorry for my ignorance related to the datatable product, it's the first time i'm using it.

I have a small question related to inline editing with a regular HTML table (no AJAX, no link to the database).

When i modify the cells, the content is never saved (after leaving the cell, the content is blank). I have tried the "saveState:True" clause but no change.

I would like to save the content and once the end-user clicks on the "Save button", parse all the HTML table and save the content to the database.

Is this possible ? Do you have any example ?

Thanks, Bye
x1484

This question has accepted answers - jump to:

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Hi @x14841003 ,

    This example here shows inline editing on local data: http://live.datatables.net/wegowafu/1/edit . You can then just use standard selectors to get the data when the ave button is pressed.

    Hope that helps,

    Cheers,

    Colin

  • x14841003x14841003 Posts: 33Questions: 9Answers: 0

    Hi Colin

    Thanks again :-)

    From the link you provided, the edit functionality works if you press the "edit" button and enter fields' values in there. After you press on "Update", the cell row is updated.

    But if you click into one cell, type something from there, as soon as you click somewhere else the cell content is lost.

    That's what i mean in fact. How can you save the content from immediate inline cell editing ?

    Thanks again !!
    x1484

  • colincolin Posts: 15,142Questions: 1Answers: 2,586
    edited June 2019 Answer ✓

    Ah, I see - that's the blur options. If you look at the page for inline, you'll see the last parameter is form-options. If you set {onBlur: 'submit'}, it will submit the data when the user clicks away.

    C

  • x14841003x14841003 Posts: 33Questions: 9Answers: 0

    Hi again Colin

    --> Thank you so much ! it works !!!

    Regards
    x1484

  • x14841003x14841003 Posts: 33Questions: 9Answers: 0

    Hi again, sorry again but how can i get (from the php perspective) the cell values after the user clicks on submit ? if you have any example... thanks again !

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Hi @x14841003 ,

    The 'Server script' tab on this page shows the server script - for inline editing by default only the changed value will get sent,

    Cheers,

    Colin

  • x14841003x14841003 Posts: 33Questions: 9Answers: 0

    Hi Colin,

    Thanks again but is there any other way ?

    I'm not so confident with the code in this staff.php code approach, where all CRUD database operations are included in the "->process( $_POST )". (I think i'm right when i read this https://editor.datatables.net/manual/php/getting-started)

    Is there any other example of server side source code where I can get the AJAX data, parse it and do my own mysql updates ?

    For example :

    editor3 = new $.fn.dataTable.Editor( {
    ajax: "trace.php",
    <...>

    And trace.php :

    <?php $data = $_POST['data']; echo json_decode($data); ?>

    Thanks so much again !
    x1484

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin
    Answer ✓

    Is there any other example of server side source code where I can get the AJAX data, parse it and do my own mysql updates ?

    I'm afraid there aren't examples of that, since the libraries we publish effectively do all of that. That said, that client / server communication that Editor is documented which provides all of the parameters submitted from the client-side and what it expects back. You can implement your server-side code based on that.

    Regards,
    Allan

  • x14841003x14841003 Posts: 33Questions: 9Answers: 0

    Hello Allan

    Thanks for this
    Bye
    x1484

This discussion has been closed.