Skip to main content

getRange()

pro version only

This functionality requires PRO version of the DHTMLX Grid (or DHTMLX Suite) package.

returns the current selection range

Usage

getRange():
| null
| {
xStart?: string | number;
xEnd?: string | number;
yStart?: string | number;
yEnd?: string | number;
};

Returns:

  • an object with the current selection range, where:
xStart(string | number) the starting column id
xEnd(string | number) the ending column id
yStart(string | number) the starting row id
yEnd(string | number) the ending row id
  • null if no range is set

Example

// this example shows retrieving of the current range
const grid = new dhx.Grid("grid_container", {
// other configuration
columns: [
{ id: "a", header: [{ text: "A" }] },
{ id: "b", header: [{ text: "B" }] },
],
data: [
{ id: "1", a: "A1", b: "B1" },
{ id: "2", a: "A2", b: "B2" },
],
rangeSelection: true
});

grid.range.setRange({ xStart: "a", yStart: "1", xEnd: "b", yEnd: "2" });
console.log(grid.range.getRange()); // -> { xStart: "a", xEnd: "b", yStart: "1", yEnd: "2" }

Related article: Work with Range Selection object

Related API: setRange()

Change log:

added in v9.2