Ext JS 4: Two Ways to Configure Selection Model in Grid

There are two ways to configure the selection model on the grid. The two configuration options are selModel and selType. Below is an example of using both. Note, the configurations that I put in are just for demonstrations purposes, not necessarily recommended.

Example 1 – selType
This only uses configuration to set up the selection model. If using all the default configs for the selection model, the configuration options in selModel are not needed.

{
	xtype: 'grid',
	title: 'My Grid',
	store: myStore //configured elsewhere
	selType: 'checkboxmodel',
	selModel: {
		checkOnly: true,
		injectCheckbox: 1
	}
	columns: [
		// configure columns here
	]
}

Example 2 – selModel
This creates the selection model and only uses selModel.

{
	xtype: 'grid',
	title: 'My Grid',
	store: myStore //configured elsewhere
	selModel: Ext.create('Ext.selection.CheckboxModel, {
		checkOnly: true,
		injectCheckbox: 1
	}),
	columns: [
		// configure columns here
	]
}

Versions: Ext JS 4.1.1

Advertisements

2 comments

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s