How can I create multiple rows based on other selected rowss?
How can I create multiple rows based on other selected rowss?
Navern
Posts: 7Questions: 1Answers: 0
Hello everyone!
I have a problem with DataTables Editor. I want to create multiple rows based on other selected rows!
Is it possible at all?
How can I duplicate multiple selected rows at the same time uses Editor?
please help me.
This discussion has been closed.
Answers
You'd need to use the multi-row API. Specifically use
create()
with the number of rows you want to create specified (i.e. the number of rows currently selected). Then userow().data()
(probably insiderows().every()
) andmultiSet()
to set the values for the fields.Allan
yes, but i want to enter different data for each selected row.
but, it just add the same data for each row..
it should look like duplicate button, for each selected row.
https://editor.datatables.net/examples/api/duplicateButton.html
can you give me a sample code?
thank you, Allan.
That's why I mentioned you'd need to use
multiSet()
insiderows().every()
- you'd need to set the value from each row being duplicated.Yes, this is something that would be covered under the support options.
Thanks,
Allan
I bought a license, but it seems that the support period has already expired
Allan, can we just buy credit to cover that issue?
Hi - yes indeed. The Quick Support 60 should be enough.
I've just done a search to see what happened to any existing credits for your account, but I don't see an Editor license for your account. Was it purchased under another account?
Thanks,
Allan
yes, my another account is: Hubone
Thanks - it looks like you have a single developer license which was purchased under that account. That doesn't come with any support credits I'm afraid.
This is an interesting question though - I'll try to make some time to knock together an example, but I can't promise exactly when at the moment (bit of a support backlog!).
Regards,
Allan
Thank you, Allan.
I just need a little kick.
Perhaps you could give a hint how to improve my code for this.
I need to open a new editing window for each selected row.
After clicking the create button, this should add as many lines as it was selected, with different data.
Here's an example:
Ideally not. The multi-row editing should mean that you don't need to do that and only a single Ajax request would be needed to duplicate any number of rows.
The issue with using
edit()
is that it is async and you can only submit one at a time. i.e. you would need to implement a queue. So get the list of rows to be duplicated and then duplicate them one at a time. That's perfectly do able, but it doesn't scale very well. The multi-row API would be more efficient, although the code is perhaps a little more complex (counterbalanced by the fact it wouldn't need a queue).Allan
Allan, I still don't understand how I can code this.
Could you send a sample code?
thanks
Yes - the quick support package would cover the work involved.
If that isn't an option, I'll try to make some free time to set up an example at some point next week, but I've got quite a backlog at the moment and can't promise that I'll get time to do it.
Allan
hey, Allan.
I bought the quick support package!
can you help me now?
so, that's what I want...
I want to be able to select multiple lines and click that button which will launch a pop up that will allow me to enter some data for each line that I selected. (Each line individually based on what I enter for each line)
I want to be able to enter new data in fields (These are new fields I want to be able to enter) all the other info from each line should be the same.
It’s like split line feature but for multiple lines.
Hi,
Thanks for picking up the support package.
This won't be what you want to hear I'm sorry to say, but what you are asking for is not supported by Editor. Specifically there is no way for it display individual data for each row that was selected. Each field will be shown only once - it will either show the value if it is the same for all fields, or a "this is a multi value field" message. You can see that happening in action on this page.
The original question in this thread, as I understood it (perhaps incorrectly) was about duplicating existing rows with the same data for each row. As you noted above:
That I can happily do, and if you can confirm that is what you want I'll provide an example of how to do that.
If you want to show the individual values for each row to allow them to be edited before then as you described in your latest post, that is not something Editor can do and I'd happily refund your support payment.
Regards,
Allan
Hi Allan, Great regret, this isn't what we want to get and it doesn't solve our problem. We need exactly what I described above. Perhaps there is some other solution... If not, could you please refund my last support payment?
Yup - no problem. That's the refund issued. I'm sorry Editor can't do what you are looking for. From the original description I thought it would, but Editor's multi-row editing ability does not extend to showing the values for each row being edited, if the values are different.
Regards,
Allan
The example in the link you posted behaves properly in the UI, but I'm seeing that it just updates those records because the request sent to the server looks exactly like an edit. It makes a PUT request with {123123: {...}, 123124: {...}, ...}
The behaviour of that example has changed slightly in 1.7 as
mode()
can now be used as a setter - i.e. change the edit action into a create. So the key difference is that theaction
submitted iscreate
.How do you have your
ajax
option set up?Allan
I see you have another thread on this topic where the Ajax configuration is shown. Let's continue the discussion there.
Allan