0
votes

I am using ExtJs6

I have a grid and a checkbox column as first column of the grid.

{ header: 'Select rows', dataIndex: 'selectedrows', xtype: 'checkcolumn' }
...
....
....
some more columns
.....

The rows can be selected by checking the chackboxes which is working fine. Now my requirement is - User can check as many rows as he wants, but I want only last checked row. For example, if user checked rows in following order row3 row2 row4 row1

Then I want row1 records as this is the last row checked by user.

To start this I tried getting grid selection as follows-

var selModel = grid.getSelectionModel();
var lngth = selModel.getSelection().length;

But here I am surprised to see the value of lngth is 0 even if I have selected 4 rows. Any idea what I am doing wrong here and how can I get last seleted row's record.

1
A checkcolumn is not a selection model. Use the checkbox selection model.Evan Trimboli

1 Answers

0
votes
Ext.create('Ext.grid.Panel', {
  title: 'Simpsons',
  store: store,
  columns: [{
      text: 'Name',
      dataIndex: 'name'
  }, {
      text: 'Email',
      dataIndex: 'email'
  }, {
      text: 'Phone',
      dataIndex: 'phone'
  }],
  height: 200,
  width: 400,
  renderTo: Ext.getBody(),
  selModel: {
      selType: 'checkboxmodel'
  }
});