Good morning,
I have a ListGrid with dependent values. To avoid user confusion, when the primary value changes I'd like to clear the dependent value. Additionally, the dependent column is required.
When I use the code below, or similar code with an explicit custom validator, two odd things happen (which I believe are related).
1) The required property on the dependent field is not checked (and custom validators do not fire).
2) The dependent value reverts back to its prior value (which is likely not appropriate for the current primary value).
Steps to reproduce:
Start with the dependent select example: http://www.smartclient.com/docs/6.5.1/a/system/reference/SmartClient_Explorer.html#_Grids_Editing_Databound.Dependent.Selects
Edit the code to look like this (aside from formatting, the only material change s are the "changed" handler on the primary value, and the "required" flag on the dependent value):
Add a new row and select a primary value and a dependent value, then save.
Edit that row and select a new primary value, do not select a dependent value, then save.
At this point the old dependent value will be in the grid with the new primary value, showing an invalid combination.
I would have expected at that point that the field would remain blank, and required validator would fire and not save the record. My theory is that since we're changing the dependent value programatically, SC is getting confused and not throwing some "dirty" flag somewhere and the validators are not being run.
Possibly unrelated but if you add allowEmptyValue: true and manually select the blank value the validators fire. That's what led me to believe that the issue is the "dirty" flag.
Is this the recommended way to clear a ListGrid editValue?
Thanks in advance. Let me know if you need anything more from me.
Rob
I have a ListGrid with dependent values. To avoid user confusion, when the primary value changes I'd like to clear the dependent value. Additionally, the dependent column is required.
When I use the code below, or similar code with an explicit custom validator, two odd things happen (which I believe are related).
1) The required property on the dependent field is not checked (and custom validators do not fire).
2) The dependent value reverts back to its prior value (which is likely not appropriate for the current primary value).
Steps to reproduce:
Start with the dependent select example: http://www.smartclient.com/docs/6.5.1/a/system/reference/SmartClient_Explorer.html#_Grids_Editing_Databound.Dependent.Selects
Edit the code to look like this (aside from formatting, the only material change s are the "changed" handler on the primary value, and the "required" flag on the dependent value):
Code:
isc.ListGrid.create({
width: 500,
height: 200,
canEdit: true,
ID: "orderList",
fields: [
{name: "quantity",
title: "Qty",
type: "integer",
width: 30
},
{name: "categoryName",
title: "Category",
editorType: "select",
optionDataSource: "supplyCategory",
autoFetchDisplayMap: false,
changed: function(form, item, value){
form.getField("itemName").clearValue();
}
},
{name: "itemName",
title: "Item",
editorType: "select",
required: true,
optionDataSource: "supplyItem",
autoFetchDisplayMap: false,
editorProperties: {
getPickListFilterCriteria: function(){
var category = this.grid.getEditedCell(this.rowNum, "categoryName");
return {category: category};
}
}
}
]
});
isc.IButton.create({
top: 225,
title: "Order New Item",
click: "orderList.startEditingNew({quantity:1})"
})
Edit that row and select a new primary value, do not select a dependent value, then save.
At this point the old dependent value will be in the grid with the new primary value, showing an invalid combination.
I would have expected at that point that the field would remain blank, and required validator would fire and not save the record. My theory is that since we're changing the dependent value programatically, SC is getting confused and not throwing some "dirty" flag somewhere and the validators are not being run.
Possibly unrelated but if you add allowEmptyValue: true and manually select the blank value the validators fire. That's what led me to believe that the issue is the "dirty" flag.
Is this the recommended way to clear a ListGrid editValue?
Thanks in advance. Let me know if you need anything more from me.
Rob
Comment