Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single Selection not working in Extjs Grid

Tags:

extjs

extjs4

This is how I set up my selection model for my grid :

var selM = Ext.create('Ext.selection.Model', {
    mode: 'SINGLE',
    toggleOnClick: true,
    allowDeselect:true
});

And then in my table I add this as a configuration paramater :

var packageGrid = Ext.create('js.grid.MyGrid', {
    selModel: selM 
});

The MULTI selection is disabled, which is great. However now nothing remains selected. If I click on a row the highlighting disappears as soon as I move the mouse away.

This could be an extjs bug. I have tried the other parameter 'SIMPLE' as well.

Here is a fiddle which shows my problem :

http://jsfiddle.net/fgkb8yw5/1/

like image 273
Oliver Watkins Avatar asked Mar 27 '15 09:03

Oliver Watkins


2 Answers

RowModel is the default so you can simply use:

selModel: {
  mode: 'SINGLE'
}

Example: http://jsfiddle.net/8mra2het/1/

like image 85
CD.. Avatar answered Oct 24 '22 00:10

CD..


It's not a bug, Ext.selection.Model is the abstract class - which shouldn't be instantiated directly. Normally - when you specify the selModel declaratively, the grid component will implement one of the grid-context appropriate sub-classes:

  • Ext.selection.CellModel
  • Ext.selection.RowModel

I updated your fiddle using RowModel to demonstrate.

like image 32
Emissary Avatar answered Oct 24 '22 00:10

Emissary