Cell Selection

21 Dec 20223 minutes to read

Cell selection can be done through simple mouse down or arrow keys (up, down, left, and right).

The grid supports two types of cell selection mode that can be set by using the cellSelectionMode property of e-grid-selectionsettings tag helper. They are:

  • Flow: The Flow value is set by default. The range of cells are selected between the start index and end index that includes in between cells of rows.
  • Box: Range of cells are selected from the start and end column indexes that includes in between cells of rows within the range.
<ejs-grid id="Grid" dataSource="@ViewBag.datasource" allowSelection="true" allowPaging="true">
        <e-grid-selectionsettings cellSelectionMode="Box" mode="Cell" type="Multiple"></e-grid-selectionsettings>
        <e-grid-pagesettings pageCount="2"></e-grid-pagesettings>
        <e-grid-columns>
            <e-grid-column field="Inventor" headerText="Inventor Name" width="140"></e-grid-column>
            <e-grid-column field="NumberofPatentFamilies" headerText="No of Patent Families" width="185" textAlign="Right"></e-grid-column>
            <e-grid-column field="Country" headerText="Country" width="120"></e-grid-column>
            <e-grid-column field="Active" headerText="Active" width="130"></e-grid-column>
        </e-grid-columns>
    </ejs-grid>
public IActionResult Index()
 {
    var orders = OrderDetails.GetAllRecords();
    ViewBag.datasource = orders;            
    return View();
 }

NOTE

Cell selection requires the mode to be Cell or Both, and type should be Multiple.

Toggle selection

The Toggle selection allows to perform selection and unselection of the particular row or cell or column. To enable toggle selection, set enableToggle property of e-grid-selectionsettings as true. If you click on the selected row or cell or column then it will be unselected and vice versa.

<ejs-grid id="Grid" dataSource="@ViewBag.datasource" allowSelection="true" allowPaging="true">
    <e-grid-selectionsettings type="Multiple" enableToggle="true"></e-grid-selectionsettings>
    <e-grid-pagesettings pageCount="2"></e-grid-pagesettings>
    <e-grid-columns>
        <e-grid-column field="Inventor" headerText="Inventor Name" width="140"></e-grid-column>
        <e-grid-column field="NumberofPatentFamilies" headerText="No of Patent Families" width="185" textAlign="Right"></e-grid-column>
        <e-grid-column field="Country" headerText="Country" width="120"></e-grid-column>
        <e-grid-column field="Active" headerText="Active" width="130"></e-grid-column>
    </e-grid-columns>
 </ejs-grid>
public IActionResult Index()
 {
   var orders = OrderDetails.GetAllRecords();
   ViewBag.datasource = orders;            
   return View();
 }

NOTE

If multi selection is enabled, then first click on any selected row (without pressing Ctrl key), it will clear the multi selection and in second click on the same row, it will be unselected.