Prevent callback transport.Read event when focus lost in the filter textbox

1 Answer 254 Views
Filter Grid TextBox
Senthilkumar
Top achievements
Rank 1
Senthilkumar asked on 16 Jun 2021, 10:52 AM

Hi Telerik Team,

I'm using k-textbox for filtering rows in a grid.

We used custom filter when type in the filter textbox we make a server call to bind also when I click outside of the textbox on the grid page again the transport.Read event gets called when it lost focus.

Is there a way to prevent this ?

Thanks for your answer.

Regards,

Senthilkumar

1 Answer, 1 is accepted

Sort by
0
Accepted
Georgi Denchev
Telerik team
answered on 21 Jun 2021, 08:12 AM

Hi, Senthilkumar,

You can stop the Read action from occurring by preventing the requestStart event of the DataSource.

let dataSource = $("#grid").data("kendoGrid").dataSource;

dataSource.one("requestStart", function(e){
    e.preventDefault();
});

You can execute the code from above in the Change event of the TextBox which is fired whenever you modify the value of the input and then click outside.

Let me know if you have any questions.

Best Regards,
Georgi Denchev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Senthilkumar
Top achievements
Rank 1
commented on 21 Jun 2021, 01:14 PM

Hi Georgi Denchev,

Thanks for your Answer, its working as expected also I have used below code and this code also working as expected which one is preferable.


if (e.type === 'change') {
e.stopImmediatePropagation();
return false;
}

Regards,
Senthilkumar
Georgi Denchev
Telerik team
commented on 24 Jun 2021, 07:36 AM

Hi, Senthilkumar,

Generally speaking the preferred method would be preventDefault as it is used in all widgets, however stopImmediatePropagation() shouldn't cause problems either.

You can read about the difference between the methods here:

https://stackoverflow.com/a/5302939 

Tags
Filter Grid TextBox
Asked by
Senthilkumar
Top achievements
Rank 1
Answers by
Georgi Denchev
Telerik team
Share this question
or