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

Vue in Kendo Native Grid at a time only open row expand

5 Answers 154 Views
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 1
Rahul asked on 07 Oct 2020, 06:59 AM

Hello All,

In vue js how to achieve at a time only one row expanding in Kendo Native Grid.

Please give the needful demo example

5 Answers, 1 is accepted

Sort by
0
Rahul
Top achievements
Rank 1
answered on 07 Oct 2020, 07:01 AM
how to set active class in master row ?
0
Petar
Telerik team
answered on 07 Oct 2020, 10:54 AM

Hi Rahul,

The targeted functionality can be implemented using the approach demonstrated in this StackBlitz project.

We have the marked in the yellow configuration in the Grid's definition. With it, what we have to do is to set the value of the "expanded" property to true/false in the array that defines the categories in the Grid.

 <Grid
    ref="grid"
    :style="{height: '550px'}"
    :data-items="categories"
    :detail="cellTemplate"
    @expandchange="expandChange"
    :expand-field="'expanded'">
    <template v-slot:myTemplate="{props}">
        <custom :data-item="props.dataItem" />
    </template>
 </Grid>

To expand/collapse the first row in the Grid, the following functions are used.

openFirstRow: function(){
  this.categories[0].expanded = true;
},        
collapseFirstRow: function(){
  this.categories[0].expanded = false;
}

I hope the provided example will help you implement the targeted functionality in your application. 

Regards,
Petar
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

0
Rahul
Top achievements
Rank 1
answered on 07 Oct 2020, 11:01 AM
Thank you Petar 
0
Rahul
Top achievements
Rank 1
answered on 07 Oct 2020, 12:47 PM

Hello Petar

how to add active class in master row ?

0
Petar
Telerik team
answered on 08 Oct 2020, 12:04 PM

Hi Rahul,

If the targeted functionality is to add/remove "active" class to the master row, based on the status of the row(extended/collapsed), this can be implemented using an approach similar to the one demonstrated in this demo

The logic that adds/removes the CSS class is implemented in the below function.

expandChange: function (event) {
    event.dataItem[event.target.$props.expandField] = event.value;
    let masrRows = document.querySelectorAll(".k-master-row");
    for (var i = 0; i < masrRows.length; ++i) {
      if(masrRows[i].children[1].innerHTML == event.dataItem.CategoryID && !masrRows[i].classList.contains('active')) {
        masrRows[i].classList.add("active")
      }
      else {
        masrRows[i].classList.remove("active")
      }
    }
},

Check the provided example and let me know if it demonstrates what you want to implement. 

Regards,
Petar
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

Asked by
Rahul
Top achievements
Rank 1
Answers by
Rahul
Top achievements
Rank 1
Petar
Telerik team
Share this question
or