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

Show/Hide Detail row on condition

6 Answers 435 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
Robert Madrian asked on 29 Jan 2020, 09:15 AM

Hi,

how to Show/Hide Detail row on condition with value from grid datasource?

robert

6 Answers, 1 is accepted

Sort by
0
Teya
Telerik team
answered on 31 Jan 2020, 02:20 PM

Hello Robert,

You can use the Grid DataBound event and create a function that iterates through the rows and expand their detail row based on a condition:

dataBound: function(e) {
    var that = this;
    var rows = e.sender.tbody.children();
    for (var j = 0; j < rows.length; j++) {
      var row = $(rows[j]);
      var dataItem = e.sender.dataItem(row);
      var country = dataItem.get("Country");
                              
       if (country == "USA") {
           that.expandRow(row);
       }
   }
},

I have created the following Dojo demonstrating the suggested behavior: 

https://dojo.telerik.com/obUQOVuk

I hope this helps!

 

Regards,
Teya
Progress Telerik

Get quickly onboarded and successful with Telerik UI for ASP.NET Core with the dedicated Virtual Classroom technical training, available to all active customers.
0
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
answered on 31 Jan 2020, 02:24 PM

Hello,

I don't want to expand a proview row but I want to hide (completely) a specific preview row!

robert

0
Teya
Telerik team
answered on 04 Feb 2020, 10:57 AM

Hello Robert,

By preview row do you mean a detail row or a grid row? By default, the detail rows are hidden, so, unfortunately, I cannot understand your requirements. You can take a look at the following Knowledge Base article on how to expand and collapse all rows and adjust the logic to work for your case:

https://docs.telerik.com/kendo-ui/knowledge-base/grid-how-to-expand-and-collapse-details-rows

Regards,
Teya
Progress Telerik

Get quickly onboarded and successful with Telerik UI for ASP.NET Core with the dedicated Virtual Classroom technical training, available to all active customers.
0
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
answered on 04 Feb 2020, 02:58 PM

found it - thanks...

                    var that = this;
                    var rows = e.sender.tbody.children();
                    for (var j = 0; j < rows.length; j++) {
                        var row = $(rows[j]);
                        var dataItem = e.sender.dataItem(row);

                        if (dataItem) {
                            var ebene = dataItem.get("Mitgliedebene");
                            if (ebene === true) {
                                row.find(".k-hierarchy-cell").html("");
                                that.collapseRow(row);
                            } else {
                                that.expandRow(row);
                            }
                        }
                    }

 

0
Mohammed
Top achievements
Rank 1
answered on 06 Feb 2020, 09:23 AM

please do you have answer for this Q

https://www.telerik.com/forums/hide-the-column-based-on-viewdata#TJPxGf35vkmP3-Y09IZD-Q

0
Teya
Telerik team
answered on 06 Feb 2020, 11:51 AM

Hi Mohammed,

Since there is a separate forum thread open for the linked issue, let's keep the conversation regarding it in the other thread to avoid confusion.

Thank you for understanding.

Regards,
Teya
Progress Telerik

Get quickly onboarded and successful with Telerik UI for ASP.NET Core with the dedicated Virtual Classroom technical training, available to all active customers.
Tags
Grid
Asked by
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
Answers by
Teya
Telerik team
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
Mohammed
Top achievements
Rank 1
Share this question
or