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

Batch edit a grid with non-nullable numeric columns

1 Answer 86 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 04 Jan 2013, 10:26 PM
So I've been working in jsFiddle for quite a while lately trying to get grid editing working the way I've envisioned.

Essentially I have a grid describing some items, and costs associated with them. When toggling a button I want to be able to prevent my editable fields from being edited which I have been able to do. Because the costs on these items are so minimal they go past 2 decimal places of significance I've had to tell the grid to use an editor in which I create a numericTextBox and edit my values from there.

Here's where I run into an issue. I can no longer figure out how to perform any required field validation of my override columns after a value has been changed. I've tried assigning it as an additional validator on the numericTextBox and as a required field in both the column definitions and dataSource to no avail...

Ideally what I want to find a null value and replace it with the default, however I have not been able to tie into any blur, validate, edit, or save events which will let me change the value to default in the numericTextBox when deleted. I would need it to not only persist to the dataSource, but also reflect the default value in the grid as well. You can see my attempt at trying to do this on blur of my numericTextBox where I attempt to set the value to 5. If you delete the value entirely sometimes the text box will flash "5.00" very briefly before saving the null value.

So on blur of a property in a batch edit I'm looking to get a non-generic grid editor control to validate that a field is required, or in the more optimal case, replace it's value with another value.

I have a link to the jsFiddle I have been using to test this out if it helps: http://jsfiddle.net/sparksterz/YFqNC/

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimiter Madjarov
Telerik team
answered on 08 Jan 2013, 04:32 PM
Hi Brian,

Thank you for contacting Telerik Support.
When you use custom editor and want to perform validation, you have to do as follows:

  1. Manually add the required and name attributes to your input field.
  2. Append an element (for example span), with a "k-invalid-msg" class to the container, which will represent the invalid message pop-up, when the input field is empty. As described the validator documentation, this is needed in order to avoid showing the message from inside the widget wrapper.
For your convenience, I've edited the jsfiddle - http://jsfiddle.net/YFqNC/11/

Regarding your second question, you can use the save event of the grid, instead of bind, to check for null value and set it to default. You can find more information in the KendoUI Grid documentation - http://docs.kendoui.com/api/web/grid#save
Greetings,
Dimiter Madjarov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Brian
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or