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

Hide dinamically button

1 Answer 104 Views
Button
This is a migrated thread and some comments may be shown as answers.
Dario
Top achievements
Rank 1
Veteran
Dario asked on 21 May 2020, 02:18 PM

Hi to all,

I need to hide a button base a model's view.

But I can't do this.

hide() and show() methods seems wrong.

 

 

1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 26 May 2020, 08:56 AM

Hello Dario,

A possible solution is to mark the button(s) that need to be hidden by binding property of the model to an attribute:

@(Html.Kendo().Button()
      .Name(Model.Name)
      .HtmlAttributes(new { type = "button", @class = "k-primary", hide=Model.Hidden })
      .Content("Test Button"))

Then you could hide/show the button(s) depending on the value of the respective attribute. Below is an example:

 $(document).ready(function () {
        $("[hide='hide']").hide()       
 });

In the above JavaScript, the marked in green code is the value coming from the model.

I hоpe this helps.

Regards,
Neli
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Button
Asked by
Dario
Top achievements
Rank 1
Veteran
Answers by
Neli
Telerik team
Share this question
or