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

Prevent Default on Edit button

2 Answers 1798 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Muhammad
Top achievements
Rank 1
Iron
Muhammad asked on 20 Jun 2020, 02:01 PM

In kendo grid when I click on the Edit button it shows the Update and Cancel button immediately. Is there any way to prevent this ?

I mean when clicking on the Edit button it should first check the condition if it is true only then show it should show the Update and Cancel buttons

Thanks

2 Answers, 1 is accepted

Sort by
0
Muhammad
Top achievements
Rank 1
Iron
answered on 20 Jun 2020, 02:04 PM

 

 

edit: function(e) {
            //$('.column-edit').closest('a').off('click').on('click', function (e) {
            //    alert('edit');
            //    return false
            //});
            $(e).unbind();
            alert('sss');
            return false;
            e.stopPropagation();
            e.preventDefault();
        }

 

But it still shows the Update and Cancel button

0
Anton Mironov
Telerik team
answered on 23 Jun 2020, 01:48 PM

Hello, Muhammad,

Thank you for the provided code.

In order to disable the Edit button by condition try the dataBound event instead of edit. When the edit event is handled it is too late to disable its default behavior. In the dataBound event handler, target the edit button by class (.k-grid-edit) and attach a click event handler to it. Get the dataItem for the current row and check the condition. If the condition returns true, prevent the default behavior of the event, and stop immediate propagation.

The full implementation could be found in the demo below:
(the condition for disabled Edit buttons is field "Units In Stock" to be less than 50)

Let me know if you have any other questions.

 

Best Regards,
Anton Mironov
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
Grid
Asked by
Muhammad
Top achievements
Rank 1
Iron
Answers by
Muhammad
Top achievements
Rank 1
Iron
Anton Mironov
Telerik team
Share this question
or