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
How can I define a range of acceptable values for data entry in the WebGrid? I want to limit both value and number of digits before and/or after the decimal.
For example, I want to limit the data to values between 0.00 and 99.99 for a field.
Thanks.
Hello,
To apply this scenario, you should set DataFormatString to “##.##” and do some validation using OnAfterExitEditMode client side event.I’ve made a sample project that similar with this scenario.In my sample, I use Northwind.mdb database and Products table. Then, at UnitPrice column, I set DataFormatString to “##.##”.
And here the validation code in WebGrid’s OnAfterExitEditMode event:
function WebGrid1_OnAfterExitEditMode(controlId, tableName, editObject) { var WebGrid1 = ISGetObject(controlId); var ColumnName = editObject.ToCellObject().Name; if (ColumnName == "UnitPrice") { var TextPrice = editObject.ToCellObject().Text; var IntPrice = parseInt(TextPrice); if (IntPrice >= 100 || IntPrice < 0) { editObject.ToCellObject().SetText("0"); editObject.ToCellObject().SetValue("0"); alert("Invalid UnitPrice Value"); return false; } else { return true; } } }
I attached my sample as well, in order to make you easily understand about my sample.
Thank you.Regards,Hans.
I have a need to change the culture sometimes.
In my example, if I change a value to "19,32", the grid changes it to "0". The javascript sees the value as "1932". How do I get this to work for an alternative culture? I still want the value to be saved to the database as "19.32".
To resolve this issue, please replace the code in OnAfterExitEditMode to this code below:
function WebGrid1_OnAfterExitEditMode(controlId, tableName, editObject) { var WebGrid1 = ISGetObject(controlId); var ColumnName = editObject.ToCellObject().Name; if (ColumnName == "UnitPrice") { var TextPrice = editObject.element.value; var IntPrice = parseFloat(TextPrice); if (IntPrice >= 100 || IntPrice < 0) { editObject.ToCellObject().SetText("0", true); editObject.ToCellObject().SetValue("0"); alert("Invalid UnitPrice Value"); return false; } else { editObject.ToCellObject().SetText(TextPrice.toString(), true); editObject.ToCellObject().SetValue(TextPrice.toString()); return true; } } }
Hope this helps. Thank you.Regards,Hans.
So, if I am using a grid with 6 different columns containing decimal types (currency), I need to write this code to handle culture settings?
Also, when I "click-into" the cell to make an edit, then leave the cell without entering a change, the value is "null" - not the value that was originally in the cell. Why?
Yes, you could use this code. However, you should modify this code (the validation) according to your needs.
I try to make an edit and leave the cell without making any changes, by using example project that I’ve gave to you in earlier post.But unfortunately, the value didn’t turn into “null”.
Would you mind to tell me how to replicate this issue? There may be a setting that I miss, in my example project.
Is there a way to place a range checker on the WebInput control?
If it should be handled the same, what function would I override ? Is there a corresponding "OnAfterExitEditMode" for WebInput?
You could use “OnDirty” client side event in WebInput.However, you should use “setTimeout” function in that event.Here’s the example snippet code, how to use “OnDirty” event:
function WebInput1_OnDirty(controlId, dirtySourceType) { var WebInput1 = ISGetObject(controlId); window.setTimeout(function () { Validate(WebInput1.GetValueData(true)); }, 300); return true; } function Validate(value) { // your validation }
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