Adding Time Format on Grid Column

1 Answer 39 Views
Grid Validation
syian
Top achievements
Rank 1
Veteran
syian asked on 02 Jul 2021, 11:42 AM

Is there any way of formating a cell on incell editing and making sure that everytime the user leaves the cell, its value is in hh:mm format?

Similar to the editing custom editor example and the unit price column.

I tried the following but it did not make any difference. I am still able to pass whatever value I want. 

...
columns: [
  { field: "time", title: "Time", width: "40px",  attributes: {style: "text-align:left;"}, headerAttributes: {style: "text-align:left;"}, format: "{0:hh:mm}" },      
],
...

I am guessing I will have to combine both datasource validation and the format option in order to achieve what I want. 

 

Thank you in advance,

Syian

1 Answer, 1 is accepted

Sort by
1
Accepted
Georgi Denchev
Telerik team
answered on 07 Jul 2021, 07:26 AM

Hi, Syian,

You are correct, you should utilize a custom validation in order to display an error when an incorrect format has been entered in the input.

You can check the Custom Validator demo for more information:

https://demos.telerik.com/kendo-ui/grid/editing-custom-validation 

I have also prepared an example in dojo which you can examine:

https://dojo.telerik.com/@gdenchev/EToBAvel 

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/.

syian
Top achievements
Rank 1
Veteran
commented on 07 Jul 2021, 01:43 PM

Hi Georgi, thank you for your answer. It worked like a charm :) I did however use an additional function, in order to make it more user friendly and save the user from adding the ":".
Georgi Denchev
Telerik team
commented on 09 Jul 2021, 11:19 AM

Hi, Syian,

I am glad the example was helpful and thank you for sharing the additional changes you made!

Tags
Grid Validation
Asked by
syian
Top achievements
Rank 1
Veteran
Answers by
Georgi Denchev
Telerik team
Share this question
or