In this article I will discuss and highlight “multiselect” within the extjs grid. With a two line addition to the grid code we are able to select multiple documents and then action them.
EXTJS in XPages series
Here are links to all of the previous articles in this series
- EXTJS in XPages #14 – Grid editing and saving data via REST CRUD
- EXTJS in XPages #13 – Totaling your columns with a groupingSummary
- EXTJS in XPages #12 – Counting categories with Grouped columns
- EXTJS in XPages #11 – Grids with Locked Column(s)
- EXTJS in XPages #10 – Grid Row Expander plugin
- EXTJS in XPages #9 – Infinite scrolling rebooted and reborn – v4.2 BufferedRenderer
- EXTJS in XPages #8 – Selecting data from the grid and opening a document
- EXTJS in XPages #7 – Doing an @Unique(@DbColumn) equivalent in the grid
- EXTJS in XPages #6 – remote sorting using the REST service
- EXTJS in XPages #5 – Infinite scroller
- EXTJS in XPages #4 – Adding a Pager
- EXTJS in XPages #3 – Creating a basic grid from a Custom Control
- EXTJS in XPages #2 – Basic Grid capabilities
- EXTJS in XPages #1 – Starting from scratch (the first grid)
Demonstration
The EXTJS in XPages demonstration database can be found at http://demo.xomino.com/xomino/Extjs.nsf/xBufferedRendererCheckBox.xsp
Download
The sample database that will accompany this series is available from the menu in the live demo database from this link – http://demo.xomino.com/xomino/Extjs.nsf
Introduction
To be able to action more than one document we want to be able to select more than one in the grid. There are two ways we can do this and we are going to look at both. In the next article we will look at how to affect change to multiple documents.
How does that work?
Within the grid configurations we are able to add a multiSelect parameter which allows us to select multiple documents. This can be achieved in the same way as you would multiselect in excel:
- Hold down the SHIFT key and click two documents, Everything inbetween will be selected as well as the two documents clicked
- Hold down the CTRL key and the documents clicked will be selected in addition to each other
- Single clicking any other document without either key held down will only select the document clicked
var grid = Ext.create('Ext.grid.Panel', { renderTo: 'gridHere', frame: true, multiSelect: true, // <----------- height: 400, title: 'Users', plugins: buffRend,
As you can see from the above picture the multiple selected documents are all highlighted.
Going one step further (if the users prefer it) you can add a “checkboxmodel” parameter to add “checkboxes” to the grid
var grid = Ext.create('Ext.grid.Panel', { renderTo: 'gridHere', frame: true, multiSelect: true, // <----------- selType: 'checkboxmodel', //<---------------- height: 400, title: 'Users', plugins: buffRend,
Not only does this give a new interface it also allows users to select and deselect all by clicking on the checkbox at the top of the grid
Conclusion
Adding multi-select support to the grid is very simple and in the next article we will look at how to take action on that