Hey folks, let’s continue to explore Ignite UI igGrid features. Here’s the link to my previous article, where I've discussed how to get started with it.

Getting Started with Ignite UI igGrid

Ignite UI igGrid control allows a number of customizations. Following are the features, we can play around with.

Let's start with the selection features and explore them one by one progressively. The Selection feature allows us to highlight the selected rows or cells. You can always intercept the selection of the events and do what your heart says with the selected rows/cells. As it highlights the selection, it adds certain CSS classes to the cells, which you can use to modify the theme at your will.

I am extending the sample code from my previous demo Getting Started with Ignite UI igGrid to explain this feature. igGrid control's config object accepts an array of the objects (features), allowing customization. To add or modify a feature, you need to add a feature object to this array. Every feature is identified by a name.

Please note, that the name of the feature starts with a capital letter.

 Capital letter

Localhost

The color/texture of the highlighted cells/rows will depend on the referenced theme. Another attribute you will see along with the feature name is "persist". It allows the grid control to persist the selected cells or the rows after you've done some filtering or sorting on it. The attribute is true by default.

Selection can be set for cells or rows, using the "mode" attribute of the selection feature. It is "rows" by default.

Mode

Select mode

Select Multiple Cells or Rows

It also allows the selection of multiple cells/rows. The attribute for it is "multiple selection" and is disabled by default.

MultipleSelection

You get a Microsoft Windows Explorer-type experience while selecting multiple rows/cells. By pressing the CTRL key, clicking the different cells will select them. It toggles the selection, every time you click on a cell/row. You can also select a cell, press the Shift key, and select another cell. It will select all the cells/rows in between.

Micrososft Window

Select Multiple Cells/Rows by dragging the mouse

You can also drag to select multiple cells or rows at one go, using the mouse after you set "mouseDragSelect" to true. It is disabled by default.

MouseDragSelect

Click and drag the mouse after you've set it to true and all the cells/rows across the range will be selected.

 Drag the mouse

Cells

Select Fields using Arrow Keys

Arrow Keys

Ignite UI igGrid control allows the "activation" of keys. Setting the "activation" attribute to true will enable users to use their arrow keys for the selection of cells/rows. Works exactly like Microsoft Windows Explorer item selection. By pressing the shift key and arrow key it will select continuous cells/rows. Keeping the CTRL key pressed, using keys to move around other cells/rows, and hitting SPACEBAR on the desired cell/row will select that particular cell or row.

Drag and Select on Touch devices

 Touch devices 

Set "touchDragSelect" to true to enable drag selection on touch-enabled devices. touchDragSelect is limited to cells only.

Wrap Around

Wrap Around 

This attribute works in conjunction with activation. If you have enabled "activation" for the grid control the selection goes seamlessly on keypress. The selection will keep moving from cell to cell even if it reaches the last cell in the grid. It starts from the first cell after reaching the last every time. This is called wrap-around.

To prevent this and limit the keyboard selection at the first and last cell, set the "wrapAround" attribute to false. It is enabled by default.

Modifying the theme

Below is a reference table if you want to customize the look and feel of the Selection feature. Add your styles and that's it!

 Theme

Download the sample code for this post here at my GitHub repo.

Well, that pretty much wraps up the Ignite UI igGrid selection feature. I'll be discussing selection events in a separate post. Hope you enjoyed reading. Please share your valuable feedback in the comments section.