iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Hello Crosslight Support,
I have a question concerning nullables and Crosslight form builder.
I have the following code in my model:
public double? Amount{get{ return (double?)this.GetValue(AmountPropertyMetadata);}set{ this.SetValue(AmountPropertyMetadata, value);}}
public static EntityProperty AmountPropertyMetadata = EntityMetadata.Register(new DataEntityProperty<MyClass, double?>("Amount", true, false, false, "", "", null, true, false, false));
And the belonging metadata property:
[Editor(EditorType.NumericTextField)][StringInput(Placeholder = "Amount")][Layout(Style = LayoutStyle.DetailOnly)]public static double? Amount;
I want to use a nullable data type, because when I create a new entry of MyClass and enter the Amount field in the UI, I don't want to clear the "0" as default entry before I can enter the real amount. I think this is not a good user experience.
Doing this with the code above works partly. When creating a new entry the form pops up and the Amount field is empty, showing only the placeholder text. Then I enter an amount, I leave the field, I get back to the amount field and clear the amount.
The result is an exception (see screenshot) while debugging and the value entered before remains in the amount field. But I want the have a clean amount field with the placeholder text.
Do you have any advice or fix?
Thanks,Thomas
Hello Yudi,
I applied the hotfix and tested again. The problem seems to be solved. Using my culture it works as intended. Hopefully it works in any other culture as well.
Thanks,
Thomas
Hi Thomas,
I implemented the changes into Crosslight FormBuilder sample and follow the steps below:
No error persist when performing the above steps. For your information, I'm using Crosslight 5.0.5000.626-experimental from NuGet.
If you are using the latest stable version (5.0.5000.607), could you please try to update the NuGet package and let me know the result?
I downloaded the FormBuilder sample but I could not find the code you changed. Searching for a nullable, I just found a DateTime?.
So, I upgraded my code with Crosslight 5.0.5000.626-exp, but nothing changed. I still get the errors. Maybe it is a cultural problem, too. The decimal delimiter can be "." (123.45) or "," (123,45). I think you have to include this in the conversion code.
I downloaded the FormBuilder sample but I could not find the code you changed.
Sorry if my previous reply causing misunderstanding. Here are the detail steps that I did to test the reported problem:
I enclosed the video which shows how the test was conducted on my device. Please find the video and the modified sample in the attachment and let me know if you find anything that I might miss during my attempt to reproduce the reported problem.
Note: The modified sample is uploaded in here.
this may work at your end and with your settings, but it does not work with my settings.
Unfortunately, I cannot record my screen like you do, so I try to describe as good as I can.
The first time I enter 123.50 into the empty Amount field. Then I set the focus to the text field above. No error and value stays as I entered it. I set the focus to the Amount field again. Then I clear the Amount field and set the focus to the text field above. The Amount field is now not empty. It shows 123,50 (! comma as decimal delimiter).
I think, this has to do with the culture settings as I wrote some posts before. My culture is German. Having different culture settings can cause problems when converting values. In one culture the dot (.) is the decimal delimiter and in another culture the comma (,) is the decimal delimiter. When you internally do a conversion and maybe a "TyrParse" you must handle this. Not matter what the decimal delimiter is, the conversion must not fail.
Please, try again with a different culture.
Hello Thomas,
Thank you for the detail explanation. I have re-test the scenario and make sure that the test device using German culture (set Settings > Language & input > Language to "Deutsch").
However, no error persist after clear the "Amount" field and set the focus to the text field above.
I have created a worklog for the Crosslight-Android development team to correctly show null value after "Amount" field is cleared. The report is filed under CROS-1128.
I'll keep this thread updated with any news I heard from the team regarding the progress of CROS-1128.
Edited on May 9, 2016 3:30 AMReason: Update recent progress of CROS-1128
Nightly-build hotfix for CROS-1128 is now available in NuGet. Per my test, user are now be able to clear the "Amount" field and left the field empty (not revert back to previous valid value) when set the focus to the text field above.
Please give it a spin and let us know how it works in your end.
Glad to hear the good news.
Should you need further assistance or run into any problems regarding our controls, feel free to post it into our forum. We would be happy to assist you again.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname