using array as data source and editing with inline editin features

using array as data source and editing with inline editin features

KostasRKostasR Posts: 24Questions: 5Answers: 0
edited December 2018 in General

Hello,

i have the requirement to use DataTables without server side scripts.

A Dataset is fetched over PDO and stored in an array.
The content of this array should be processed and modified by PHP. Even new records can be added.
Afterwards the user can modify and add these records. I would prefer some kind of "inline editing".
Then the records should be processed again by PHP and written to (/inserted into /updated in) the database using PDO.

This an example of how the array could look like. Adding new fields to process the array wouldn't be a problem.
For new inserted records negative RowIDs would be possible or any other form of data type. I'm very flexible at this point so it shouldn't be a big of a problem.
The user should be able to edit each field and add new records.
Can you provide an example how this requirement can be accomplished using DataTables?

{
  "data": [
    {
      "RowId": "1",
      "first_name": "John",
      "last_name": "Miller",
      "email": "John.Miller@office.net",
      "age": "61"
    },
{
      "RowId": "2",
      "first_name": "Peter",
      "last_name": "Wulf",
      "email": "Peterg.Wulf@office.net",
      "age": "63"
    }
 ]
 } 

regards,
Kostas

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,494Questions: 1Answers: 10,470 Site admin
    Answer ✓

    Hi Kostas,

    This example shows how you can do local table editing with DataTables and Editor. You would then use rows().data() to get the full data set when the user is ready to submit it to the server.

    By default Editor will use the current date stamp (plus a counter) as the new row id, but you can use preSubmit to override that and assign your own negative values.

    Allan

  • KostasRKostasR Posts: 24Questions: 5Answers: 0

    perfect Allan thank you.

This discussion has been closed.