Kendo Spreadsheet Cancel Leaving Cell

1 Answer 357 Views
Spreadsheet
Daniel
Top achievements
Rank 1
Iron
Daniel asked on 01 Nov 2022, 05:10 PM | edited on 01 Nov 2022, 05:13 PM

I have written my own data validation in a Kendo Spreadsheet that executes when OnChange is fired. From what I can tell, this event happens when I change the contents of the cell then either click on another cell or scroll using the arrow key -- in Html this would have been onBlur. To that end, everything is working well. What I am not able to do though is reset the focus back to the cell that was in error. Within the OnChange function I execute sheet.range(rangeString).select(), but Kendo ignores this and continues moving to the next cell when OnChange is completed. Is there a way to stop this action?

 

Thank you in advance.

Daniel
Top achievements
Rank 1
Iron
commented on 01 Nov 2022, 05:20 PM | edited

I thought I had this resolved but I didn't. 

1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 04 Nov 2022, 10:29 AM

Hello Daniel,

I am not sure about the exact implementation of the validation on your side. However, I would suggest you if you need to select the same cell when the validation fails, use the range select method and select the same range again. Below is an example:

change: function(e){          
       if(e.range.value().toString().length > 3){
            var selection = e.range.select()
            var row = e.range._ref.topLeft.row -1;
            var col = e.range._ref.topLeft.col;         
            e.sender.activeSheet().range(row, col).select();
      }
}

In the example above the same cell will be selected again if the entered value is longer than 3 characters. Here is a Dojo example to demonstrate the behavior.

I hope you will find the provided information helpful.

Regards,
Neli
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/.

Tags
Spreadsheet
Asked by
Daniel
Top achievements
Rank 1
Iron
Answers by
Neli
Telerik team
Share this question
or