Add multiple rows at once
Add multiple rows at once
Hello,i want the make the Editor to insert multiple rows by a single call.
I have 4 fields with 2 datepickers (username,absence_type,start_date,end_date) and i want to insert multiple rows(according to the difference between edn_date-start_date) for a specific user and absence_type.
Now,i have to open n times the Editor modal window to insert n rows which is not convenient.
The username and absence_type will be the same for the n rows,The only field that will be different is the date field (start_date-end_date).
Thank you.
Answers
I just found that https://datatables.net/forums/discussion/40962/multiple-row-insert-based-on-multiple-select-inputs
Is there anything newer about this matter?
I can't edit the above code from that post so that it only loops the date field (start_date untill end_date).The username and absence_type are fixed.
You might be able to use
multiSet()
- see my example in this thread. Likewise, this thread here shows how to add multiple rows based on the value in one cell.Colin
Can you help me here on this?
How to use
multiset()
to insert many similar rows but with different date field (as many rows as the differnce in days ,end_date - start_date) .At the moment if i want to insert an employee's absence for 5 consecutive days,i have to make the same thing that is add a new row 5 times.
Thank you in advance
One option is to use a loop with
field().multiSet()
, for example:http://live.datatables.net/guwafemu/99/edit
The CSV Import plugin uses the same technique.
Is this what you are looking for?
Kevin
Yes something like that.
I think i have to use it in the editor's modal box.Do i have to use the
onpresubmit
event in Editor??Or
preventdefault
?Thank you again!
That depends on your business logic. You could do in an event, or within a button, like Kevin's example above.
Colin