0

Is it normal that when I have a grid and I select the first row, then I try to select another row it actually deselects the first row without selecting the new one? It seems like a feature to me 'cause it happens to all my grids even with the simplest settings. Is there a way to remove this option?

PentaKon
  • 4,139
  • 5
  • 43
  • 80

2 Answers2

0

Yes, this is the default behavior. You can set the selection mode to multiselect, which allows you to select multiple rows by holding the CTRL or SHIFT keys.

I'm unsure which version of ExtJS you are using, but if it is version 4.2, you can set the mode of the selection model to 'SIMPLE' in order to achieve the behavior you are expecting.

Ext.create('Ext.panel.Grid', {
    // other grid configs
    selModel: {
        mode: 'SIMPLE'
    }
}

The docs for the mode config are here: http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.selection.Model-cfg-mode

forgivenson
  • 4,394
  • 2
  • 19
  • 28
  • I did find the selModel you mention but didn't really understood what SIMPLE mode did. THanks for the answer – PentaKon Jul 07 '14 at 14:53
  • Actually now that I tested out the solution it is not what I want. I essentially want a grid that behaves like the windows file system does. Each click deselects everything you have selected (no matter if it is the first or any other item) and ctrl and shift are used for multi select. Essentially I want a mode: 'MULTI' but without the default behavior for the first grid row – PentaKon Jul 08 '14 at 07:08
  • I don't know what you mean by "default behavior of the first grid row", but `'MULTI'` is what you just described, like Windows. – forgivenson Jul 08 '14 at 12:10
  • If you choose THE FIRST row on a grid, then try to choose another row, it will SHOULD: -Deselect first row. -Select new row. However what it DOES: -Deselect first row. It doesn't select the new row I pressed. That only happens if you try to go from row 1 to any other row. From any other row it happens like windows. – PentaKon Jul 08 '14 at 14:59
  • Odd. I have never seen that happen. I have grids with multi select, and they work just fine, even when selecting the first row first. Here is a fiddle which is just a simple grid with multi select turned on: https://fiddle.sencha.com/#fiddle/7g7 – forgivenson Jul 08 '14 at 15:16
  • That's what I'm looking for but that's not how it works on my side of things... I don't use inline data though but that shouldn't be a problem... I'm gonna check it back again tomorrow when I go to work and try some things. – PentaKon Jul 08 '14 at 19:40
  • I have tons of other grids I've written that use remote stores, and they work exactly like the example I gave. Something else in your grid must be causing this issue. Do you have any listeners for when a row is selected? Try stripping it down to the bare minimum, until it works correctly, and then slowly add in new features until you find with one breaks it. – forgivenson Jul 08 '14 at 19:47
  • THe problem was with Extjs 4.2.1 it seems. When I upgraded to 4.2.2 everything worked out perfectly. – PentaKon Jul 17 '14 at 14:45
0

It seems that this was an error with my version of ExtJS. My coworkers were using 4.2.2 while I was using 4.2.1. When I upgraded to the new version everything got fixed by itself. Weird since this does not seem to have been documented...

PentaKon
  • 4,139
  • 5
  • 43
  • 80