It is possible to select multiple rows in Syncfusion GridControl at one time. You can perform various operations over the selected rows, for example, copy their data to the clipboard, delete them, and so on. Note that before selecting grid rows, you need to locate them within the grid. For example, you can search for the desired rows by the cells’ text values.
The following sections describe the approaches that can be used to select multiple rows in the GridControl:
To perform these actions, TestComplete should have access to internal objects, properties and methods of the GridControl object. For this purpose, the .NET Application Support plugin must be installed and enabled. When testing Syncfusion GridControl controls, use specific methods and properties of the corresponding |
General Notes
It is possible to select multiple rows in the GridControl from TestComplete scripts in two ways:
-
By selecting the desired rows with mouse or keyboard while holding Ctrl or Shift.
-
By using internal properties and methods of the GridControl object.
The first approach simulates user interaction with the grid control. It implies selecting rows by clicking on their headers. However, this approach depends on several grid options: it requires the grid control to be configured so that the row headers are displayed and multiple row selection by the mouse is enabled (see below).
The approach that uses internal properties methods of the GridControl object is simpler and more stable. It lets you select multiple grid rows even if this is impossible to do using user interaction with the grid control.
In this topic, we will use both approaches. In your scripts, you can use the approach that suits your needs the best.
Option That Affects Row Selection in GridControl
The GridControl object has the AllowSelection
property that specifies how the users can select grid rows, columns and cells. This property holds a set of flags that enable various aspects of the selection behavior. The table below lists flags that affect multiple row selection:
Flag | Description |
---|---|
“Row” (1) | It is possible to select an entire row by clicking on its header. |
“Multiple” (16) | It is possible to select multiple rows by Ctrl-clicks on row headers. |
“Shift” (32) | It is possible to select row ranges by Shift-clicks on row headers. |
In scripts, you can check whether the AllowSelection
property contains these flags by doing any of the following:
- Search for the string representation of the flag value in the string returned by the
AllowSelection.OleValue
property (see Working With Strings to learn how you can do this). - Compare the
AllowSelection.value___
value with the flag value (numeric) using the bitwise logical OR operator.
Simulating Selections With Mouse
The users can select rows in the GridControl by clicking on row headers. Multiple row selections are possible by pressing Ctrl or Shift while selecting the rows. Holding Ctrl while selecting the row adds it to the current selection, and holding Shift extends selection to the selected row.
You can simulate Ctrl- and Shift-clicks on row headers using the Click
action applied to the grid control. This action takes the coordinates of the point to click, and the optional Shift parameter that specifies the key to be “pressed” when performing the click. To select several rows, you can use successive Click
calls with the desired row header coordinates and the needed Shift parameter values.
To determine coordinates of a particular row header cell, you can use the following code:
rect = GridObj.RangeInfoToRectangle ( GridObj.GridCellsRange.Cell ( RowIndex, 0 ) )
GridObj is the GridControl object and RowIndex is the zero-based absolute index of the desired row. For more information on identifying GridControl rows and columns, see Accessing Rows, Columns and Cells in Syncfusion GridControl. The resulting rect
object is a .NET System.Drawing.Rectangle
object that holds the grid-relative coordinates of the row header cell.
Note however, that the row headers may not be displayed, so it may be impossible to click on them. You can check whether the row headers are visible by examining the GridObj.Model.Cols.Hidden.Item(0)
value: if it is False, then row headers are visible, otherwise they are hidden.
Below is an example that illustrates how you can simulate Ctrl- and Shift-clicks on row headers in the GridControl to select multiple rows.
Example
JavaScript, JScript
function Main ()
{
var p, Grid, RowIndexes;
// Obtain the application process and the grid object
p = Sys.Process("GridControlSort");
Grid = p.WinFormsObject("Form1").WinFormsObject("gridControl1");
// Select rows 10-20
SelectRange (Grid, 10, 20);
aqUtils.Delay (1000);
// Select the specified rows
RowIndexes = new Array (10, 12, 15, 17, 23);
SelectRows (Grid, RowIndexes);
}
function SelectRange (Grid, StartRowIndex, EndRowIndex)
{
// Check if row headers are displayed
if (Grid.Model.Cols.Hidden.Item(0))
Log.Error ("Cannot click on row headers because row headers are hidden.")
else
{
// Check if row selection is possible
if (((Grid.AllowSelection.value__ & 1) == 0) || // Check if AllowSelection contains the Rows flag
((Grid.AllowSelection.value__ & 32) == 0)) // Check if AllowSelection contains the Shift flag
Log.Error("Grid does not support selection of row ranges.")
else
{
ClickRowHeader (Grid, StartRowIndex, skNoShift);
ClickRowHeader (Grid, EndRowIndex, skShift);
}
}
}
function SelectRows (Grid, RowIndexes)
{
// Check if row headers are displayed
if (Grid.Model.Cols.Hidden.Item(0))
Log.Error ("Cannot click on row headers because row headers are hidden.")
else
{
// Check if row selection is possible
if (((Grid.AllowSelection.value__ & 1) == 0) || // Check if AllowSelection contains the Rows flag
((Grid.AllowSelection.value__ & 16) == 0)) // Check if AllowSelection contains the Multiple flag
Log.Error("Grid does not support selection of multiple rows.")
else
{
ClickRowHeader (Grid, RowIndexes[0], skNoShift);
for (var i=1; i<RowIndexes.length; i++)
ClickRowHeader (Grid, RowIndexes[i], skCtrl);
}
}
}
function ClickRowHeader (Grid, RowIndex, Shift)
{
var rect;
// Check if row headers are displayed
if (! Grid.Model.Cols.Hidden.Item(0))
{
// Make row visible
Grid.ScrollCellInView_3(RowIndex, 0);
// Get the row header coordinates
rect = Grid.RangeInfoToRectangle (Grid.GridCellsRange.Cell(RowIndex, 0));
Grid.Click (rect.X + rect.Width/2, rect.Y + rect.Height/2, Shift);
}
else
Log.Error ("Cannot click on row header because row headers are hidden.");
}
Python
def Main ():
# Obtain the application process and the grid object
p = Sys.Process("GridControlSort")
Grid = p.WinFormsObject("Form1").WinFormsObject("gridControl1")
# Select rows 10-20
SelectRange (Grid, 10, 20)
aqUtils.Delay (1000)
# Select the specified rows
RowIndexes = list(10, 12, 15, 17, 23)
SelectRows (Grid, RowIndexes)
def SelectRange (Grid, StartRowIndex, EndRowIndex):
# Check if row headers are displayed
if (Grid.Model.Cols.Hidden.Item[0]):
Log.Error ("Cannot click on row headers because row headers are hidden.")
else:
# Check if row selection is possible
if (((Grid.AllowSelection.value__ & 1) == 0) or # Check if AllowSelection contains the Rows flag
((Grid.AllowSelection.value__ & 32) == 0)): # Check if AllowSelection contains the Shift flag
Log.Error("Grid does not support selection of row ranges.")
else:
ClickRowHeader (Grid, StartRowIndex, skNoShift)
ClickRowHeader (Grid, EndRowIndex, skShift)
def SelectRows (Grid, RowIndexes):
# Check if row headers are displayed
if (Grid.Model.Cols.Hidden.Item[0]):
Log.Error ("Cannot click on row headers because row headers are hidden.")
else:
# Check if row selection is possible
if (((Grid.AllowSelection.value__ & 1) == 0) or # Check if AllowSelection contains the Rows flag
((Grid.AllowSelection.value__ & 16) == 0)): # Check if AllowSelection contains the Multiple flag
Log.Error("Grid does not support selection of multiple rows.")
else:
ClickRowHeader (Grid, RowIndexes[0], skNoShift)
for i in range(1, RowIndexes.length-1):
ClickRowHeader (Grid, RowIndexes[i], skCtrl)
def ClickRowHeader (Grid, RowIndex, Shift):
# Check if row headers are displayed
if not Grid.Model.Cols.Hidden.Item[0]:
# Make row visible
Grid.ScrollCellInView_3(RowIndex, 0)
# Get the row header coordinates
rect = Grid.RangeInfoToRectangle (Grid.GridCellsRange.Cell(RowIndex, 0))
Grid.Click (rect.X + rect.Width/2, rect.Y + rect.Height/2, Shift)
else:
Log.Error ("Cannot click on row header because row headers are hidden.")
VBScript
Sub Main
Dim p, Grid, RowIndexes
' Obtain the application process and the grid object
Set p = Sys.Process("GridControlSort")
Set Grid = p.WinFormsObject("Form1").WinFormsObject("gridControl1")
' Select rows 10-20
Call SelectRange (Grid, 10, 20)
Call aqUtils.Delay (1000)
' Select the specified rows
RowIndexes = Array (10, 12, 15, 17, 23)
Call SelectRows (Grid, RowIndexes)
End Sub
Sub SelectRange (Grid, StartRowIndex, EndRowIndex)
' Check if row headers are displayed
If Grid.Model.Cols.Hidden.Item(0) Then
Call Log.Error ("Cannot click on row headers because row headers are hidden.")
Else
' Check if row selection is possible, i.e. if AllowSelection contains the Rows and Shift flags
If ((Grid.AllowSelection.value__ And 1) = 0) Or ((Grid.AllowSelection.value__ And 32) = 0) Then
Call Log.Error ("Grid does not support selection of row ranges.")
Else
Call ClickRowHeader (Grid, StartRowIndex, skNoShift)
Call ClickRowHeader (Grid, EndRowIndex, skShift)
End If
End If
End Sub
Sub SelectRows (Grid, RowIndexes)
' Check if row headers are displayed
If Grid.Model.Cols.Hidden.Item(0) Then
Log.Error ("Cannot click on row headers because row headers are hidden.")
Else
' Check if row selection is possible, i.e. if AllowSelection contains the Rows and Multiple flags
If (((Grid.AllowSelection.value__ And 1) = 0) Or ((Grid.AllowSelection.value__ And 16) = 0)) Then
Log.Error("Grid does not support selection of multiple rows.")
Else
Call ClickRowHeader (Grid, RowIndexes(0), skNoShift)
For i=1 To UBound(RowIndexes)
Call ClickRowHeader (Grid, RowIndexes(i), skCtrl)
Next
End If
End If
End Sub
Sub ClickRowHeader (Grid, RowIndex, Shift)
Dim rect
' Check if row headers are displayed
If Not Grid.Model.Cols.Hidden.Item(0) Then
' Make row visible
Call Grid.ScrollCellInView_3(RowIndex, 0)
' Get the row header coordinates
Set rect = Grid.RangeInfoToRectangle (Grid.GridCellsRange.Cell(RowIndex, 0))
Call Grid.Click (rect.X + rect.Width/2, rect.Y + rect.Height/2, Shift)
Else
Call Log.Error ("Cannot click on row header because row headers are hidden.")
End If
End Sub
DelphiScript
procedure SelectRange (Grid, StartRowIndex, EndRowIndex); forward;
procedure SelectRows (Grid, RowIndexes); forward;
procedure ClickRowHeader (Grid, RowIndex, Shift); forward;
procedure Main;
var p, Grid, RowIndexes : OleVariant;
begin
// Obtain the application process and the grid object
p := Sys.Process('GridControlSort');
Grid := p.WinFormsObject('Form1').WinFormsObject('gridControl1');
// Select rows 10-20
SelectRange (Grid, 10, 20);
aqUtils.Delay (1000);
// Select the specified rows
RowIndexes := CreateVariantArray (0, 4);
RowIndexes[0] := 10; RowIndexes[1] := 12;
RowIndexes[2] := 15; RowIndexes[3] := 17;
RowIndexes[4] := 23;
SelectRows (Grid, RowIndexes);
end;
procedure SelectRange (Grid, StartRowIndex, EndRowIndex);
begin;
// Check if row headers are displayed
if Grid.Model.Cols.Hidden.Item(0) then
Log.Error ('Cannot click on row headers because row headers are hidden.')
else
begin
// Check if row selection is possible
if (((Grid.AllowSelection.value__ and 1) = 0) or // Check if AllowSelection contains the Rows flag
((Grid.AllowSelection.value__ and 32) = 0)) then // Check if AllowSelection contains the Shift flag
Log.Error ('Grid does not support selection of row ranges.')
else
begin
ClickRowHeader (Grid, StartRowIndex, skNoShift);
ClickRowHeader (Grid, EndRowIndex, skShift);
end
end
end;
procedure SelectRows (Grid, RowIndexes);
var i : OleVariant;
begin
// Check if row headers are displayed
if Grid.Model.Cols.Hidden.Item(0) then
Log.Error ('Cannot click on row headers because row headers are hidden.')
else
begin
// Check if row selection is possible
if (((Grid.AllowSelection.value__ and 1) = 0) or // Check if AllowSelection contains the Rows flag
((Grid.AllowSelection.value__ and 16) = 0)) then // Check if AllowSelection contains the Multiple flag
Log.Error('Grid does not support selection of multiple rows.')
else
begin
ClickRowHeader (Grid, RowIndexes[0], skNoShift);
for i:=1 to VarArrayHighBound(RowIndexes, 1) do
ClickRowHeader (Grid, RowIndexes[i], skCtrl);
end
end
end;
procedure ClickRowHeader (Grid, RowIndex, Shift);
var rect : OleVariant;
begin
// Check if row headers are displayed
if not Grid.Model.Cols.Hidden.Item(0) then
begin
// Make row visible
Grid.ScrollCellInView_3(RowIndex, 0);
// Get the row header coordinates
rect := Grid.RangeInfoToRectangle (Grid.GridCellsRange.Cell(RowIndex, 0));
Grid.Click (rect.X + rect.Width/2, rect.Y + rect.Height/2, Shift);
end
else
Log.Error ('Cannot click on row header because row headers are hidden.');
end;
C++Script, C#Script
function Main ()
{
var p, Grid, RowIndexes;
p = Sys["Process"]("GridControlSort");
Grid = p["WinFormsObject"]("Form1")["WinFormsObject"]("gridControl1");
// Select rows 10-20
SelectRange (Grid, 10, 20);
aqUtils["Delay"] (1000);
// Select the specified rows
RowIndexes = new Array (10, 12, 15, 17, 23);
SelectRows (Grid, RowIndexes);
}
function SelectRange (Grid, StartRowIndex, EndRowIndex)
{
// Check if row headers are displayed
if (Grid["Model"]["Cols"]["Hidden"]["Item"](0))
Log["Error"]("Cannot click on row headers because row headers are hidden.")
else
{
// Check if row selection is possible
if (((Grid["AllowSelection"]["value__"] & 1) == 0) || // Check if AllowSelection contains the Rows flag
((Grid["AllowSelection"]["value__"] & 32) == 0)) // Check if AllowSelection contains the Shift flag
Log["Error"]("Grid does not support selection of row ranges.")
else
{
ClickRowHeader (Grid, StartRowIndex, skNoShift);
ClickRowHeader (Grid, EndRowIndex, skShift);
}
}
}
function SelectRows (Grid, RowIndexes)
{
// Check if row headers are displayed
if (Grid["Model"]["Cols"]["Hidden"]["Item"](0))
Log["Error"]("Cannot click on row headers because row headers are hidden.")
else
{
// Check if row selection is possible
if (((Grid["AllowSelection"]["value__"] & 1) == 0) || // Check if AllowSelection contains the Rows flag
((Grid["AllowSelection"]["value__"] & 16) == 0)) // Check if AllowSelection contains the Multiple flag
Log["Error"]("Grid does not support selection of multiple rows.")
else
{
ClickRowHeader (Grid, RowIndexes[0], skNoShift);
for (var i=1; i<RowIndexes["length"]; i++)
ClickRowHeader (Grid, RowIndexes[i], skCtrl);
}
}
}
function ClickRowHeader (Grid, RowIndex, Shift)
{
var rect;
// Check if row headers are displayed
if (! Grid["Model"]["Cols"]["Hidden"]["Item"](0))
{
// Make row visible
Grid["ScrollCellInView_3"](RowIndex, 0);
// Get the row header coordinates
rect = Grid["RangeInfoToRectangle"](Grid["GridCellsRange"]["Cell"](RowIndex, 0));
Grid["Click"](rect["X"] + rect["Width"]/2, rect["Y"] + rect["Height"]/2, Shift);
}
else
Log["Error"]("Cannot click on row header because row headers are hidden.");
}
Using the GridControl.Selections Property
The GridControl object has the Selections
property that lets you manage the rows, columns and cells selected in the grid. Using methods of the GridModelSelections
object returned by the GridControl.Selections
property, you can select or unselect the desired grid elements. The following table list some methods that you can use to change the grid selection. For more information on using the GridModelSelections
object, please refer to the Syncfusion Essential Grid documentation.
Method | Description |
---|---|
GridObj.Selections.Add(GridRangeInfoObj) |
Adds the specified range of grid elements to the selection. |
GridObj.Selections.Remove(GridRangeInfoObj) |
Unselects the specified range of grid elements. |
GridObj.Selections.SelectRange(GridRangeInfoObj, Select) |
Adds or removes the specified range of grid elements from the selection. The Select parameter specifies if the range should be selected (True) or unselected (False). |
GridObj.Selections.Clear() |
Unselects all selected rows, column and cells in the grid. |
As you can see, all of these methods work with GridRangeInfo
objects that represent the range of grid elements. You can create an instance of this object using the following instructions:
GridObj.GridCellsRange.Row (RowIndex)
- Creates aGridRangeInfo
object corresponding to the row with the specified absolute index.GridObj.GridCellsRange.Rows (StartRowIndex, EndRowIndex)
- Creates aGridRangeInfo
object corresponding to the rows in a specified range.
The following example demonstrates how you can use the GridControl.Selections
property in scripts. Note that using the GridControl.Selections
property, it is possible to select multiple rows even if the grid’s AllowSelection
property does not allow it. However, in this example we check the AllowSelection
property before selecting rows, and if the row selection is disabled we report an error and do not perform the row selection.
Example
JavaScript, JScript
function Main ()
{
var p, Grid, RowIndexes;
// Obtain the application process and the grid object
p = Sys.Process("GridControlSort");
Grid = p.WinFormsObject("Form1").WinFormsObject("gridControl1");
// Select rows 10-20
SelectRange (Grid, 10, 20);
aqUtils.Delay (1000);
// Clear selection
ClearSelection (Grid);
aqUtils.Delay (1000);
// Select multiple rows
RowIndexes = new Array (10, 12, 15, 17, 23);
SelectRows (Grid, RowIndexes);
}
function SelectRange (Grid, StartRowIndex, EndRowIndex)
{
// Check if the grid supports row selection
// (i.e. if AllowSelection contains the Rows flag)
if ((Grid.AllowSelection.value__ & 1) == 0)
Log.Error ("Grid does not support row selection.")
else
{
// Clear the previous selection
Grid.Selections.Clear();
// Selects the specified range of rows
Grid.Selections.Add (Grid.GridCellsRange.Rows(StartRowIndex, EndRowIndex));
}
}
function SelectRows (Grid, RowIndexes)
{
// Check if the grid supports row selection
// (i.e. if AllowSelection contains the Rows flag)
if ((Grid.AllowSelection.value__ & 1) == 0)
Log.Error ("Grid does not support row selection.")
else
{
// Clear the previous selection
Grid.Selections.Clear();
// Select the specified rows
for (var i=0; i<RowIndexes.length; i++)
Grid.Selections.Add (Grid.GridCellsRange.Row(RowIndexes[i]));
}
}
function ClearSelection (Grid)
{
Grid.Selections.Clear();
}
Python
def Main ():
# Obtain the application process and the grid object
p = Sys.Process("GridControlSort")
Grid = p.WinFormsObject("Form1").WinFormsObject("gridControl1")
# Select rows 10-20
SelectRange (Grid, 10, 20)
aqUtils.Delay (1000)
# Clear selection
ClearSelection (Grid)
aqUtils.Delay (1000)
# Select multiple rows
RowIndexes = list(10, 12, 15, 17, 23)
SelectRows (Grid, RowIndexes)
def SelectRange (Grid, StartRowIndex, EndRowIndex):
# Check if the grid supports row selection
# (i.e. if AllowSelection contains the Rows flag)
if ((Grid.AllowSelection.value__ & 1) == 0):
Log.Error ("Grid does not support row selection.")
else:
# Clear the previous selection
Grid.Selections.Clear()
# Selects the specified range of rows
Grid.Selections.Add (Grid.GridCellsRange.Rows(StartRowIndex, EndRowIndex))
def SelectRows (Grid, RowIndexes):
# Check if the grid supports row selection
# (i.e. if AllowSelection contains the Rows flag)
if ((Grid.AllowSelection.value__ & 1) == 0):
Log.Error ("Grid does not support row selection.")
else:
# Clear the previous selection
Grid.Selections.Clear()
# Select the specified rows
for i in range(0, RowIndexes.length-1):
Grid.Selections.Add (Grid.GridCellsRange.Row(RowIndexes[i]))
def ClearSelection (Grid):
Grid.Selections.Clear()
VBScript
Sub Main
Dim p, Grid, RowIndexes
' Obtain the application process and the grid object
Set p = Sys.Process("GridControlSort")
Set Grid = p.WinFormsObject("Form1").WinFormsObject("gridControl1")
' Select rows 10-20
Call SelectRange (Grid, 10, 20)
Call aqUtils.Delay (1000)
' Clear selection
Call ClearSelection (Grid)
Call aqUtils.Delay (1000)
' Select multiple rows
RowIndexes = Array (10, 12, 15, 17, 23)
Call SelectRows (Grid, RowIndexes)
End Sub
Sub SelectRange (Grid, StartRowIndex, EndRowIndex)
' Check if row selection is possible
' (i.e. if AllowSelection contains the Rows flag)
If (Grid.AllowSelection.value__ And 1) = 0 Then
Call Log.Error ("Grid does not support row selection.")
Else
' Clear the selection
Grid.Selections.Clear
' Select the specified range of rows
Call Grid.Selections.Add (Grid.GridCellsRange.Rows(StartRowIndex, EndRowIndex))
End If
End Sub
Sub SelectRows (Grid, RowIndexes)
' Check if row selection is possible
' (i.e. if AllowSelection contains the Rows flag)
If (Grid.AllowSelection.value__ And 1) = 0 Then
Log.Error ("Grid does not support row selection.")
Else
' Clear selection
Grid.Selections.Clear
' Select the specified rows
For i=0 To UBound(RowIndexes)
Call Grid.Selections.Add (Grid.GridCellsRange.Row(RowIndexes(i)))
Next
End If
End Sub
Sub ClearSelection (Grid)
Grid.Selections.Clear
End Sub
DelphiScript
procedure SelectRange(Grid, StartRowIndex, EndRowIndex); forward;
procedure SelectRows (Grid, RowIndexes); forward;
procedure ClearSelection (Grid); forward;
procedure Main;
var p, Grid, RowIndexes : OleVariant;
begin
// Obtain the application process and the grid object
p := Sys.Process('GridControlSort');
Grid := p.WinFormsObject('Form1').WinFormsObject('gridControl1');
// Select rows 10-20
SelectRange(Grid, 10, 20);
aqUtils.Delay (1000);
// Clear selection
ClearSelection (Grid);
aqUtils.Delay (1000);
// Select multiple rows
RowIndexes := CreateVariantArray (0, 4);
RowIndexes[0] := 10; RowIndexes[1] := 12;
RowIndexes[2] := 15; RowIndexes[3] := 17;
RowIndexes[4] := 23;
SelectRows (Grid, RowIndexes);
end;
procedure SelectRange(Grid, StartRowIndex, EndRowIndex);
begin
// Check if the grid supports row selection
// (i.e. if AllowSelection contains the Rows flag)
if (Grid.AllowSelection.value__ and 1) = 0 then
Log.Error ('Grid does not support row selection.')
else
begin
// Clear the previous selection
Grid.Selections.Clear;
// Selects the specified range of rows
Grid.Selections.Add (Grid.GridCellsRange.Rows(StartRowIndex, EndRowIndex));
end
end;
procedure SelectRows (Grid, RowIndexes);
var i : OleVariant;
begin
// Check if the grid supports row selection
// (i.e. if AllowSelection contains the Rows flag)
if (Grid.AllowSelection.value__ and 1) = 0 then
Log.Error ('Grid does not support row selection.')
else
begin
// Clear the previous selection
Grid.Selections.Clear;
// Select the specified rows
for i:=0 to VarArrayHighBound(RowIndexes, 1) do
Grid.Selections.Add (Grid.GridCellsRange.Row(RowIndexes[i]));
end;
end;
procedure ClearSelection (Grid);
begin
Grid.Selections.Clear;
end;
C++Script, C#Script
function Main ()
{
var p, Grid, RowIndexes;
// Obtain the application process and the grid object
p = Sys["Process"]("GridControlSort");
Grid = p["WinFormsObject"]("Form1")["WinFormsObject"]("gridControl1");
// Select rows 10-20
SelectRange (Grid, 10, 20);
aqUtils["Delay"] (1000);
// Clear selection
ClearSelection (Grid);
aqUtils["Delay"] (1000);
// Select multiple rows
RowIndexes = new Array (10, 12, 15, 17, 23);
SelectRows (Grid, RowIndexes);
}
function SelectRange (Grid, StartRowIndex, EndRowIndex)
{
// Check if the grid supports row selection
// (i.e. if AllowSelection contains the Rows flag)
if ((Grid["AllowSelection"]["value__"] & 1) == 0)
Log["Error"]("Grid does not support row selection.")
else
{
// Clear the previous selection
Grid["Selections"]["Clear"]();
// Selects the specified range of rows
Grid["Selections"]["Add"](Grid["GridCellsRange"]["Rows"](StartRowIndex, EndRowIndex));
}
}
function SelectRows (Grid, RowIndexes)
{
// Check if the grid supports row selection
// (i.e. if AllowSelection contains the Rows flag)
if ((Grid["AllowSelection"]["value__"] & 1) == 0)
Log["Error"]("Grid does not support row selection.")
else
{
// Clear the previous selection
Grid["Selections"]["Clear"]();
// Select the specified rows
for (var i=0; i<RowIndexes["length"]; i++)
Grid["Selections"]["Add"](Grid["GridCellsRange"]["Row"](RowIndexes[i]));
}
}
function ClearSelection (Grid)
{
Grid["Selections"]["Clear"]();
}
See Also
Working With Syncfusion GridControl
Accessing Rows, Columns and Cells in Syncfusion GridControl
Obtaining Selected Rows in Syncfusion GridControl
Selecting Cells in Syncfusion GridControl
Iterating Through Rows in Syncfusion GridControl