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

Initial value not updated from inner field

3 Answers 26 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jean-François
Top achievements
Rank 1
Jean-François asked on 02 Oct 2013, 12:43 PM
Hi, 

We stumbled upon a limitation of the grid and we'd like to suggest a fix.

The problem has to do with the grid and a custom field inside of it in inline editing grid (I haven't tested cell editing, but it's most likely the same). If we use, say, a DropDownList editor, the initial value will not be set. 

The issue is that if we have a dropdownlist with an initial value, the user could leave it at that and submit the row. However, since the initial value was never changed, we'd be getting a "null" instead. 

Our solution was to trigger the "change" event on the dropdown, which was enough to update the value into the grid's datasource.

I feel like this is unclear, so here's a jsfiddle : http://jsfiddle.net/jni_/3G7FK/
In the editor, I added a "see value" link that reads from the grid datasource. Add an item and click on it. You'll see that it alerts a 0. Change to value, and you'll be set. In edition mode, this is not a problem  either. 

Simply firing an initial "change" event will force the initial value to be taken into account. 

Thanks,
Jni

PS : I'm sorry - I didn't realize there was a "grid" forum separate from the asp.net mvc grid. Can you please move it?

3 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 04 Oct 2013, 06:06 AM
Hello Jean,

You are using older version of the framework, try to update to the latest official:

http://jsfiddle.net/3G7FK/3/


Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jean-François
Top achievements
Rank 1
answered on 04 Oct 2013, 12:08 PM
Hi, 

The JSFiddle you submitted displays the same erroneous behavior. We use 2013.2.918 and we have the same issue. I've updated my fiddle to use this version too : http://jsfiddle.net/jni_/3G7FK/

The same issue happens, if you add a row, click "see value" without picking something from the dropdown list, you will see a "0" in the alert, instead of a 1.

Thanks,
Jni
0
Petur Subev
Telerik team
answered on 08 Oct 2013, 08:46 AM
Hello again Jean,

It seems I misunderstood the question. Basically there is no such option with value equal to 0 and the first selected item in the list is '1', however the value for the newly created item is still 0 because no change event was triggered.

I would suggest you to set initial value to '1' for that field.

e.g.

http://jsfiddle.net/3G7FK/5/


schema: {
                   model: {
                       id: "ProductID",
                       fields: {
                           ProductID: {
                               editable: false,
                               nullable: true
                           },
                           ProductName: {
                               validation: {
                                   required: true
                               }
                           },
                           UnitPrice: {
                               type: "number",
                               validation: {
                                   required: true,
                                   min: 1
                               }
                           },
                           Discontinued: {
                               type: "boolean"
                           },
                           UnitsInStock: {
                               type: "number",
                               defaultValue:1,
                               validation: {
                                   min: 0,
                                   required: true
                               }
                           }
                       }
                   }


Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Jean-François
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Jean-François
Top achievements
Rank 1
Share this question
or