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

Unable to delete numeric or date value and have model update??

11 Answers 113 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 25 Apr 2012, 10:23 AM
I am using the MVVM and Datasource frameworks with the Kendo UI controls, so the control is bound via MVVM to a shared datasource. This works well with all controls when updating values. It even works fine when completely deleting values of text-like controls. The issue is with numeric or date controls, where empty string is a violation, thus NULL is used.

So for DatePicker and NumericTextBox, when a value is already present, selecting the text in the control thru the UI and deleting it, does not update the underlying datasource. Thru inspection and walking code, I can see that the controls do indeed have their value set to NULL, so it appears to be in the observer and not the controls.

Anyone else unable to delete values successfully or is this just me??

Thanks!
Mike

11 Answers, 1 is accepted

Sort by
0
Michael
Top achievements
Rank 1
answered on 26 Apr 2012, 07:46 AM
So nobody has experienced this or is it nobody has tried or has a use case where they allow nullable dates or numeric values?

The repro case is pretty quick and straight-forward too, so I can't see it being anything I am doing.
1) Create a simple model with a date or numeric property and have it set to some value; use the kendo.observable wrapper around the model object.
2) Add an input control.  
3) Add the data-binding attributes, binding 'value' to your model property.
4) Configure the input as either a Kendo DatePicker or NumericTextBox.
5) Call the MVVM bind and pass in your simple model.
6) Now select and delete the value in the box.
7) Check your model and see that it still has the same value as before.
(I used both the blur and change events to confirm as well checking much later on too, just to make sure not a timing issue. Also, change the value to another value and see that your model is verified to update as expected using the same events.)

Any validation by someone would be cool. Thanks!
Mike
0
Rosen
Telerik team
answered on 27 Apr 2012, 09:02 AM
Hello Michael,

I'm afraid that I'm unable to observed such behavior using the provided information. Please take a look at the following jsFiddle test page, maybe I'm missing something obvious:

Kind regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Michael
Top achievements
Rank 1
answered on 30 Apr 2012, 04:31 PM
Hmmm, well yeah, I dunno. Example works fine, even changed the model read to be direct, instead of using the "get" accessor just to see. I confirmed the Kendo libraries are like-for-like, so that is the same. So I guess I will go back to the drawing board and see what could be different in my actual setting.

Thanks for checking into this! Stand by...

Mike
0
Michael
Top achievements
Rank 1
answered on 30 Apr 2012, 10:11 PM
OK Rosen, I have what we need. It took several tries of reproducing the pertinent environment in my scenario, to figure just what is the difference. The one thing that appears to make a difference, is if the model is slightly more complex (embedded). In my case, I have a binder composite object with the model as a property of it. I pass in the binder object to the Kendo bind. And on the input bindings, I prefix the property name I want to bind to the input with the property name from this composite object that points to my model (dot notation).

For example, a binder object of ClientBinder has a property ClientBinder.MainModel that contains the observable model. And the input bindings would be as such: data-bind="value: MainModel.TotalNetWorth" and the binding call would be kendo.bind($('form'), ClientBinder). The reason for this composite object is I have another view model off the same ClientBinder object, for other binding concerns, and I bind it all up in one call.

That all works except in the scenario I originally described. I have updated the jsFiddle example that demonstrates the exact issue for both numeric and date types: http://jsfiddle.net/wBNZR/21/ 

Please advise- thanks!
Mike
0
Rosen
Telerik team
answered on 02 May 2012, 02:02 PM
Hello Michael,

Thank you for the test page. The issue you are facing is caused by the fact that at the point at which the View is bind to the ViewModel, the ClientBinder is converted to a ObservableObject. However, in the official release the inner ObservableObjects will be converted once again. This in your case will result in two separate instances of MainModel, thus the code in click handlers is pointing to the old instance which is not actually bound to the View. However, this has been already addressed and you may try the latest internal build to see if there is change in the observed behavior.

Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Michael
Top achievements
Rank 1
answered on 02 May 2012, 03:38 PM
OK, I can try the internal build. However, the description you provide doesn't seem to fit though. For example, why would changing the value to anything else work, but just not the blanks? Meaning, try the example, and change the numeric control to some number and change the date control to some date and notice that the model does indeed update just fine.

The issue is specifically only with blanks (nulls) and nothing else. Does this still fit with your description of the problem?

Thanks,
Mike
0
Michael
Top achievements
Rank 1
answered on 03 May 2012, 02:54 AM
Please see my previous post, but for grins, I tried the internal build 423. No change, which based on my post above, doesn't surprise me. I actually noticed an issue or breaking change with that build too, where using the 'get' accessors in a calculated model property returns 'undefined' but that is a different topic.

Anyway, please advise because I don't think you were describing the same behavior and regardless, it is not addressed in the internal build for either the DatePicker or NumericTextBox.

Thanks,
Mike
0
Rosen
Telerik team
answered on 04 May 2012, 08:19 AM
Hello Michael,

Indeed, you are correct the latest internal build does not include the fix for the issue you have described. However, it will be available with the next internal build. 

Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Michael
Top achievements
Rank 1
answered on 04 May 2012, 06:15 PM
OK, understood. Is there a target date for the next internal build? I will be releasing software soon and it will be nice to include this fix. Additionally, is there an easy workaround to force the MVVM update, in the interim?

Thanks,
Mike
0
Michael
Top achievements
Rank 1
answered on 04 May 2012, 11:29 PM
Update: I noticed 503 was released yesterday so I tried that one. Same thing - no werky, so I don't know if you meant the next internal build after yesterday's, then.

Please advise. Alternately, a workaround in the meantime would be nice too.

Thanks,
Mike
0
Rosen
Telerik team
answered on 07 May 2012, 01:49 PM
Hi Michael,

I'm afraid that the 503 (May 3rd) release does not contain the fix in question as it is older than my previous post. Newer internal build will be available most probably within a week.

Also please note that internal builds are not suitable to be used in production environment but only for testing/development as they did not went through complete QA process. 

Greetings,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
MVVM
Asked by
Michael
Top achievements
Rank 1
Answers by
Michael
Top achievements
Rank 1
Rosen
Telerik team
Share this question
or