Skip to content
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

Cannot use Editor and Multiple Row Selection at same time #240

Closed
ghiscoding opened this issue May 11, 2018 · 1 comment
Closed

Cannot use Editor and Multiple Row Selection at same time #240

ghiscoding opened this issue May 11, 2018 · 1 comment

Comments

@ghiscoding
Copy link
Collaborator

ghiscoding commented May 11, 2018

Please note that Inline Editing and Row Selection are not currently working, but there's a separate issue #68 for that (and a possible fix in there too).

However once you get over that separate issue, I found out that using Editor and Multiple Row Selection (with the checkboxSelectorPlugin) is not possible. The reason is because Editor don't work unless you enable the flag enableCellNavigation: true, however this flag is also used to toggle from a Single Selection to a Multiple Selections, as shown below

  • Single Selection enableCellNavigation: true
  • Multiple Selections enableCellNavigation: false

Since this flag enableCellNavigation is required for the Editor to work, the Multiple Selection will indeed never work.

We can trace the problem to the canCellBeActive function call on this line (shown below)

// this optimisation causes trouble - MLeibman #329
//if ((activeCell != cell.cell || activeRow != cell.row) && canCellBeActive(cell.row, cell.cell)) {
if (canCellBeActive(cell.row, cell.cell)) {
  if (!getEditorLock().isActive() || getEditorLock().commitCurrentEdit()) {
    scrollRowIntoView(cell.row, false);

    var preClickModeOn = (e.target && e.target.className === Slick.preClickClassName);
    setActiveCellInternal(getCellNode(cell.row, cell.cell), null, preClickModeOn);
  }
}

and the real problem is that the canCellBeActive function checks for the enableCellNavigation flag to be enabled, else it will return that the cell cannot be active.

function canCellBeActive(row, cell) {
-      if (!options.enableCellNavigation || row >= getDataLengthIncludingAddNew() ||
+      if (/*!options.enableCellNavigation ||*/ row >= getDataLengthIncludingAddNew() ||
          row < 0 || cell >= columns.length || cell < 0) {
        return false;
      }
  ....

If comment out this check (as shown on top), it fixes my problem and I'm wondering why the canCellBeActive has this enableCellNavigation check?
If that really has to be there, then why do we even do a canCellBeActive check to get the Editor to work?

I really need this to work for my current App, that is Editor + Multiple Row Selection. So I hope we can find a resolution to this (possibly the code I commented out). I actually never understood why enableCellNavigation: true is required for the Editor to work!?

@6pac
I can create a PR for that as well, just let me know what is the best approach to fix this issue

@ghiscoding
Copy link
Collaborator Author

Actually I was using the wrong flag to toggle Single to Multiple Selections. The flag to use is the following

Single Selection
grid.setSelectionModel(new Slick.RowSelectionModel({selectActiveRow: true}));

Multiple Selection
grid.setSelectionModel(new Slick.RowSelectionModel({selectActiveRow: false}));

I still don't understand why Editors cannot be used without enableCellNavigation but it's not the end of the world, I can live with that. I will close the issue since I was really using the wrong flag.

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

No branches or pull requests

1 participant