|
#1
|
|||
|
|||
|
I have a problem in conditional validation, I have a drop down and a text box and on text box I have to validate based on the value selected in drop down. Like I have some value to be selected from drop down as email, phone number,username etc. and If user selected email from drop down then on text field I need to perform email validation and if user selected username then I need to perform username validation on text box.
Can any one give me any suggestion how to achieve such requirement in smartclient. Using smartclient 8 |
|
#2
|
|||
|
|||
|
You are looking for something like:
Code:
validators: [
{ type: "readOnly", fieldAppearance: "hidden", validateOnChange: true,
applyWhen: {fieldName: "FieldType", operator: "equals", value: "email" }
}
]
|
|
#3
|
|||
|
|||
|
Hi David,
Thanks for your quick response.. I am looking for something like you provided But the problem what I am facing that my validation doesn't look for the condition which I am providing. Like I would like to perform email validation on text only if user has selected email (from drop down). And facing same problem when I use your code also, as below Code:
this.actionListGrid = isc.ListGrid.create({
ID: "actionListGrid",height:"100%",width:"100%",stopOnErrors:true,
alternateRecordStyles:true, showEdges:false,canHover:true,
fixedRecordHeights: false,wrapCells:false,border:"1px solid #cccccc",
canReorderFields: false,autoFetchData: false,validateByCell:true,
fields:[
{name:"aname",title:"Action To Perform",width:"50%", editorType:"comboBox",valueMap:actionsJSON},
{name:"avalue",title:"Value(Optional)",width:"40%"
,validators:[{
type: "invalidNumberOrEmailCheck",
validateOnChange: true,
fieldAppearance: "hidden",
//expression: "actionListGrid.getCellValue('aname')=\"FORWARD_MESSAGE\"",
applyWhen: {fieldName: "aname", operator: "equals", value: "FORWARD_MESSAGE" },
errorMessage: "Please provide a valid Email or US Number as value"
}
]
Code:
actionsJSON = {"FORWARD_MESSAGE":"Forward to Email/Number","MOVE_MESSAGE":"Move to Trash", "REPLY_MESSAGE":"Auto reply", "PB_POST":"Post to Portal","PB_STATUS_UPDATE":"Portal status update","PB_NOTE":"Post a note to Portal"};
Problem with this is when user selects Auto Reply then also validation of email/Number gets performed But I need to perform another validation. Last edited by dilip_gupta; 6th Jul 2011 at 07:00.. |
|
#4
|
|||
|
|||
|
Can any one give any suggestion/Idea how to achieve such Requirement using custom validation
Thanks!! in Advance Last edited by dilip_gupta; 6th Jul 2011 at 06:59.. |
|
#5
|
|||
|
|||
|
That solution should work and it does in forms but not in a grid because the applyWhen check is run against the previously stored record values, if any, instead of the edit values. This is based on a quick glance at the code and not actual testing. Note also that if you setup one or more validators on a field with an applyWhen "equals" condition it should actually fail to run any of the validators for a new grid record.
In your example there should be one validator per selectable action and the applyWhen determines which validator(s) should be processed. |
|
#6
|
|||
|
|||
|
I have actually tested this scenario with the latest SC nightly and I am able to conditionally apply validators in a ListGrid row (editByRow) successfully. I just modified the Feature Explorer massUpdate sample by adding a conditional validator to the population column based on the continent.
Code:
{name:"population",
formatCellValue:"isc.Format.toUSString(parseInt(value))",
validators: [
{ type: "integerRange", validateOnChange: true, max: 100000,
applyWhen: {fieldName: "continent", operator: "equals", value: "Asia" }
}
]},
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ConcurrentModificationException in LoadDSTag | xml-silent | Technical Q&A | 1 | 16th Jan 2011 18:32 |
| Problem during evaluation re: updating joined data | peterunivex | Smart GWT Technical Q&A | 16 | 11th Jan 2011 09:06 |
| Upload / Download DMI | kfang | Smart GWT Technical Q&A | 12 | 7th Dec 2010 13:38 |
| Conditional validation | Diether | Technical Q&A | 5 | 3rd Dec 2008 12:45 |
| server side conditional required validation | CUE_TheZenith | Technical Q&A | 1 | 10th Dec 2007 11:19 |