Add multiple rows at once

Add multiple rows at once

mihalispmihalisp Posts: 127Questions: 22Answers: 0
edited January 15 in Editor

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

  • mihalispmihalisp Posts: 127Questions: 22Answers: 0
  • mihalispmihalisp Posts: 127Questions: 22Answers: 0

    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.

  • colincolin Posts: 9,806Questions: 0Answers: 1,623

    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

  • mihalispmihalisp Posts: 127Questions: 22Answers: 0

    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

  • kthorngrenkthorngren Posts: 10,609Questions: 25Answers: 2,416

    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

  • mihalispmihalisp Posts: 127Questions: 22Answers: 0

    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!

  • colincolin Posts: 9,806Questions: 0Answers: 1,623

    That depends on your business logic. You could do in an event, or within a button, like Kevin's example above.

    Colin

Sign In or Register to comment.