Author Topic: Multi-selection fails with initial selection  (Read 231 times)

Mikael Andersen

  • Pro OEM
  • Newbie
  • *
  • Posts: 10
    • View Profile
Multi-selection fails with initial selection
« on: July 02, 2026, 07:11:54 pm »
Hi at pqgrid,

We experienced a problem with initial selection being set and the use of "Shift+click" to do multi-cell selection.
Its reproducable in demo following these steps,

* Open demo: https://paramquery.com/pro/demos/grid_parts
* Insert this line after creating grid, f.x. on line 102: grid.setSelection({ rowIndx: 0, colIndx: 0})
* Run (top, leftmost cell is selected as expected)
* Hold shift and click on a different cell to do a block selection

Nothing happens and this error is displayed in console:
Uncaught TypeError: can't access property "r1", n is undefined
    resize https://paramquery.com/pro2/content/js11.2.0/pqgrid.min.js?4:32
    resizeOrReplace https://paramquery.com/pro2/content/js11.2.0/pqgrid.min.js?4:32
    onCellMouseEnter https://paramquery.com/pro2/content/js11.2.0/pqgrid.min.js?4:32
  ...

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6557
    • View Profile
Re: Multi-selection fails with initial selection
« Reply #1 on: July 03, 2026, 05:25:51 pm »
Please use grid.Range() API instead of setSelection.

Code: [Select]
        grid.Range({
            r1: 0,
            c1: 0,
            firstR:0,
            firstC:0
        }).select();

Ref: https://paramquery.com/pro/api#method-Range
« Last Edit: July 03, 2026, 05:27:24 pm by paramvir »

Mikael Andersen

  • Pro OEM
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Multi-selection fails with initial selection
« Reply #2 on: July 06, 2026, 11:10:29 am »
Hi Paramvir,
Thx for always fast and solid reply.

We actually did similar modification after studying source-code before this reply was posted, but considered it a temporary solution as these firstR, firstC variables are not part of the public API description.
Should we consider the suggested approach a workaround or a permanent solution?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6557
    • View Profile
Re: Multi-selection fails with initial selection
« Reply #3 on: July 06, 2026, 07:46:27 pm »
You are completely right to question the use of firstR and firstC since they are not explicitly detailed in the public API documentation.

Currently, these properties are internally necessary to establish the anchor point for subsequent "Shift+click" operations when setting an initial selection programmatically.

You can safely use this approach as a permanent solution. We will either formalize these properties in the official API documentation or ensure that any future internal optimizations remain fully backward-compatible so your implementation won't break.