Select specific table rows on button click
Select specific table rows on button click
huba_sbf
Posts: 16Questions: 6Answers: 1
Hello,
I have a table with 20 rows which need to be edited on a daily basis. 15 of them will always have to be edited with the same values each.
Is it possible to have a button which simply selects these 15 rows, in order to benefit of "Multi-row editing"? An example would be great.
Thank you.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Yes that should be quite possible. The documentation here details how to create a custom button. In it you would use the
rows().select()
method to select your 15 rows and then the Editor API methods (such asedit()
) to trigger the editing.Allan
Thank you Allan for the quick reply, I've got as far as adding a button to select all the rows, by adding the following button:
...
Any chance to help me out in how to only select the 15 I need? Let's say I have a column called "fruit" and I would like to select all rows where fruit = "apples".
Thanks again.
I would suggest using
rows().every()
and looping over each row to see if you want to select it or not based on the data in it.Allan
Hey Allan,
I have tried the following:
for: console.log( this.data().type ), I have "Undefined
for console.log( this.data() ), please see the attached image.
Thank you.
Can you put the
console.log()
statements inside theevery
function and run it again please? I'd need to know what their values are in there.Thanks,
Allan
Hey Allan,
I have put the console.log() statements and everything seemed fine, yet the selection wasn't made.
Then I have realized what my code was missing some brackets, so instead of
this.select;
I actually needed
this.select();
Thanks for your help, you have made my day!
Finally we have: