-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Click and drag to select multiple rows #565
Comments
If you use Shiny, this is possible with the help of jquery-ui. |
Edit: Sorry, but it was not a duplicate. But I guess we are very unlikely to implement it by ourselves. Pull requests will be welcomed! |
Here is the Shiny implementation with jquery-ui:
@yihui Is it possible to attach a dependency to an instance of datatable ? So that we could do that without Shiny, if we were able to attach jquery-ui as a dependency. |
Better, allows to select several blocks of rows:
Double-click on the table to remove all selections. |
Yes, I've found the way:
But |
Dear @stla, thank you very much for your help. Your code is really useful. If you want to reproduce this, order by Sepal.Lenght column, select the first 5 rows and reorder two more times by this column. I wonder if you can help me to solve this, I don't have experience with JS. Thank you again! |
@jordimartorell Thanks for the feedback. You are right. But sorry, I don't know how to solve this issue. |
@jordimartorell I've found a solution ! Replace the callback with:
Then use the option
Please give it a try and tell me whether it works. |
@stla it works perfect now! |
@jordimartorell You're welcome. Thanks again for the feedback. FYI this code is on my blog. I have just updated it to include this solution. |
@stla sorry to disturb you again, but I realised that there is a problem when retrieving which rows are selected. It seems that only the first row clicked is stored in the variable "input$dt_rows_selected", so I can't get the rows selected by dragging. Here it is an example, the selected rows are printed in the R console:
|
@jordimartorell Hmm sorry that sounds hard. |
This code prints the selected rows but there's an issue: when you unselect a row, it still appears. I dont know how to solve that.
|
@jordimartorell I think I managed (this was hard). Please try this one:
|
@jordimartorell Here is a cleaner version. Use this one.
|
@stla Awesome, your code works perfectly! Thank you very much and congratulations for your blog. |
Hi again @stla I faced another problem. I think that the solution is easy, but I'm not able to handle it. For instance, if you have dt1 and dt2, you can access to input$dt1_rows_selected and input$dt2_rows_selected, but only to one input$selectedRows. So the solution would be to generate a name for this variable related to the DT name. Thanks again! |
@jordimartorell This is already done on my blog :-). Have a look. |
Wonderful, that's exactly what I needed :-) |
Hi @stla ! I used the above code you mentioned for the click and drag to select the rows and it works great. But now I want to implement the same for the cells. Is there any way you can help with it? |
Here is the first step:
|
Thank You @stla ! The code works perfect. Implemented it and tried for my application. |
Good morning and thank you for this awesome package.
Although it is possible to select multiple rows at a time using shift + click, I think that selecting multiple rows clicking and dragging (similar to Excel) would be a great improvement, given that, for many users, this is more intuitive than using shift + click.
Thanks in advance!
The text was updated successfully, but these errors were encountered: