Skip to content

Handle row selection when serverSide is on #48

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

demetris-manikas
Copy link

Hi!
This is my go at the problem described in issue #46.
The code is not complete yet but it works for row selection.
I will go ahead to implement the cell and column selection as soon as you give me a green light about this PR.
I used Set and Arrays which I am not sure that are acceptable to use.
I can switch Set for an Array but the performance for big data sets will be very poor.

The difficult part is to handle the selection extention with shift-click when skipping pages.
I see some ways of handling it

  1. Ignore the event all together when the table does not contain the starting row
  2. Silently call the table's ajax request to get the skipped rows and hold on to their respective ids
  3. Use a user provided callback to get the skipped ids. (Same as the previous but the application can only load row id's instead of whole rows which is most efficient)

Thanks in advance for your time

@AllanJard
Copy link
Contributor

I think that is looking good so far for a client-side solution - awesome! Thanks for the PR.

Regarding shift click across pages when thinking about this kind of thing before, I'd imagined sending an Ajax or socket call to the server to stay that row selection has happened and then the server can keep track of what rows are selected. It will mean a lot more Ajax calls (so socket probably best, since we'd need to query what is selected on DataTables page load as well). That is my current plan for CloudTables with server-side processing at least.

@demetris-manikas
Copy link
Author

Well... having the server keeping track of the selections will not always be a viable solution.
The app I currently work on for instance, by design does not keep any "session data", so the client must know it all.

I was wondering if there exist any publicly available tests that I could use.

@AllanJard
Copy link
Contributor

The unit tests are in this repo. We have a VM image that can get things up and running quickly: https://bitbucket.org/sprymedia/dev/src/master/unit_tests/vagrant.fedora.27/ . I had thought we had documentation on the image, but I can't actually see it - will ask my colleague Colin about docs for it - although that will be new year now as he is on annual leave.

Regarding the server not being available - does that not mean that server-side processing is therefore impossible?

@demetris-manikas
Copy link
Author

It does not seem that I can access the repo :(.
I was probably misunderstood about the server.
In the app i work on there is a full blown server side but the state of the app is held
on the client side.

@AllanJard
Copy link
Contributor

Bother - sorry. I thought we'd opened up access to that repo, but apparently not.

For the moment I think I'll need to run the unit tests on a locally merged copy. Sorry! We need to make that easier in future.

@demetris-manikas
Copy link
Author

Hi!
I have it working now.
The code is still far from complete but there are some things that I would like to discuss before heading on.
My main concern is that the code will get bloated and confusing implementing a lot of different selection modes.
Also not being able to run any tests makes the task almost impossible...
My go would be to create a separate file that will handle only server side data sources and only row selection.
From then on it would be your decision to whether try to incorporate it or to publish it as a different file or plugin.

@AllanJard
Copy link
Contributor

This is brilliant - thank you. I was actually going to doing this implementation soon myself. I'll go through this in detail when I get to that point (shouldn't be too far away) and get back to you then.

@demetris-manikas
Copy link
Author

Hi. Three months have past. Any chance of making progress soon?

@AllanJard
Copy link
Contributor

I hope so yes. I'm hoping to start looking at this feature soon.

@AllanJard
Copy link
Contributor

I really like how you've implemented this - nice one! Are you happy with it being merged and released under the MIT license?

I'll change the use of Set so it works with older browsers and I think there are implications for API such as data fetching, that I'm not yet sure how to handle, but over all I think this is looking really good.

@demetris-manikas
Copy link
Author

Thanks. :)
You can go ahead and release it under the MIT license.
The use of Set is a big optimization so I suggest its use when available.
As for the API my opinion is that the default data fetching should be as proposed in the code (commented)
and it should also be replaceable by a user function.
Cheers

@xJuvi
Copy link

xJuvi commented Jun 2, 2024

Any chance for resolve the merge conflicts and merge this nice feature?

@demetris-manikas
Copy link
Author

@xJuvi I don't think it has anything to do with the conflicts. This has been been forgotten here for ages. I kept on using my fork up until I stopped using datatables due to changing job.

@AllanJard
Copy link
Contributor

No indeed - it is me having not prioritised it over other work yet. I've got a todo list a mile long (as I'm sure we all have) and I've just not been able to focus on this one. Sorry.

@demetris-manikas
Copy link
Author

@AllanJard np :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants