Grid selection property top & bottom rows always 0

Posted by: grace.l91 on 22 April 2018, 10:07 am EST

    • Post Options:
    • Link

    Posted 22 April 2018, 10:07 am EST

    I am trying to perform a remove action based on the user selected cells. I know there is a isSelected property per row but i do not want to iterate through each row to determine this (for performance reasons). So i thought to user the selection property to find which rows the user has selected. I’ve slightly modified your code in below fiddle. Open console log and check and uncheck multiple rows. The selection cell range is always 0.

    I’m not sure if there are any better ways.

    http://jsfiddle.net/pq58z0yj/23/

    
     for (
          var i = this.grid.selection.bottomRow;
          i >= this.grid.selection.topRow;
          i--
        ) {
       
          if (this.grid.rows[i].isSelected) {
            // this.grid.editableCollectionView.remove(
            //   this.grid.rows[i].dataItem
            // );
          }
    
    

    Thank you.

  • Posted 22 April 2018, 10:14 am EST

    Edit , On my local build with latest npm package the top and bottom row are not zero but still the results are inconsistent. if row 0 and 4 are selected i am only being shown top and bottom rows are 4. If only one is selected i am seeing -1.

  • Posted 23 April 2018, 5:58 am EST

    Hi,

    The selection property returns the active selection range only. It does not check for isSelected property of rows thus you are getting 0 as cell range always. You can confirm this by selecting some other cell(by clicking grid cell) and then check the selection.

    If you wish to selected multiple non-contiguous rows and get selected items, a more efficient way would be to set the grid’s selectionMode to ‘ListBox’ and then get the selectedItems via the selectedItems property.

    Please refer to following example :-http://jsfiddle.net/sqrv4aaz/

    ~Manish

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels