This is a migrated thread and some comments may be shown as answers.

Grid Selection not working properly

3 Answers 849 Views
This is a migrated thread and some comments may be shown as answers.
Sebastiaan
Top achievements
Rank 1
Sebastiaan asked on 10 Aug 2018, 09:06 AM

Hi!

I have a problem with the grid selection feature. When I select multiple rows, and I have subscribed to the @change event on the Kendo Vue Grid, the event returns the proper row keys. But when i deselect one of the rows, an empty array is returned, while there are still rows selected (minus the one I have just deselected). The behaviour I would expect is for the event to return al currently selected rows, not an empty array. Does anyone have a solution to this? I need the information to bind to another component. Any help would be greatly appreciated! Below 

<template>
    <kendo-grid
      id="grid"
      ref="gridRef"
      :data-source="dataSource"
      :columns="columns"
      :resizable="resizable"
      :filterable="filterable"
      @change="onChangeSelection($event)">
    </kendo-grid>
</template>

 

// Event Handler
onChangeSelection(event: any) {

    console.log(event.sender.selectedKeyNames()); //Returns '[]' instead of [1, 2, 3 ...] when there are stil rows selected

    this.selectedKeys = event.sender.selectedKeyNames();

 }

3 Answers, 1 is accepted

Sort by
0
Accepted
Plamen
Telerik team
answered on 13 Aug 2018, 11:46 AM
Hello,

In such case we rather recommend getting the selected rows and their properties from the dataItems as for example in the code below:
change: function(e) {
    var selectedRows = this.select();
    var selectedDataItems = [];
    for (var i = 0; i < selectedRows.length; i++) {
      var dataItem = e.sender.dataItem(selectedRows[i]);
      selectedDataItems.push(dataItem.name);
    }
    console.log(selectedDataItems);// contains all selected data items
  }


Regards,
Plamen
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Fernando
Top achievements
Rank 1
answered on 05 Jan 2020, 07:05 AM
I try to do the same but I have an error: TypeError: this.select is not a function
0
Plamen
Telerik team
answered on 06 Jan 2020, 06:09 AM

Hi,

You can try to use e.sender.select() instead of this.select() when referring the kendo widget.

Regards,
Plamen
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Asked by
Sebastiaan
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Fernando
Top achievements
Rank 1
Share this question
or