multiple add functionality

multiple add functionality

arjun_adhikariarjun_adhikari Posts: 32Questions: 0Answers: 0
edited July 2012 in DataTables 1.9
Hello Allan,

In datatables i was wondering if its possible to add multiple rows at a single go.
what i require in my datatables is multiple users with same access be created in one single go rather than creating them one at a time so what i need is that in my add form the userid text box takes suppose 4 number of id's with other data being just the same and when i execute it should save the 4 id's along with their corresponding data.
Can this functionality be achieved as i am already using multiple delete functionality.

Arjun

Replies

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

    I presume that you are using Editor here? There are two ways you could achieve what you are looking for:

    1. Have your input, as your describe taking 4 numbers (comma separated, or regex range style?), and your server script would realise what format is being used and do the multiple insert required. The on the client-side, in the onSubmitSuccess event fired by Editor you could call the DataTables fnReloadAjax plug-in to get the full data set from the server: http://datatables.net/plug-ins/api#fnReloadAjax .

    2. The alternative is to use Editor to submit multiple individual requests to insert 1 row at a time, which can be done using the API. You would use the 'buttons' option in the 'create' method ( http://editor.datatables.net/api/#create ) to break the data apart and 'submit' multiple requests to add data.

    If you are only going to be adding say up-to 5 rows at a time then the second option might be the easiest to implement, but since it requires a different XHR for every new row, it can take a little bit of time, and your users would likely notice that for more than 5 rows (depending on the network latency etc).

    Allan
  • arjun_adhikariarjun_adhikari Posts: 32Questions: 0Answers: 0
    Hello Allan,
    thanks for the reply ,
    i forgot to mention that i was using jeditable plugin for adding and deleting.
    anyways i was able to achieve what i had asked for by implementing the 1st way stated by you
    Many thanks for clearing up my doubt.

    Arjun
This discussion has been closed.