Hi Experts,
how would you manage it, to get a editable datagrid with fields "from" and "to", which both should a validator like "from" must be less equal to field "to"
I did the following:
$.extend($.fn.validatebox.defaults.rules, {
$.extend($.fn.validatebox.defaults.rules, {
from: {
validator: function(value, param){
var ed1 = $('#Tolerances_grid').datagrid('getEditor', {index:my_single_update_index,field:'TO'});
var to_value = $(ed1.target).val()
return to_value >= value;
},
message: 'From must be lesser than or equals To.'
},
to: {
validator: function(value, param){
var ed2 = $('#Tolerances_grid').datagrid('getEditor', {index:my_single_update_index,field:'FROM'});
var from_value = $(ed2.target).val()
return from_value <= value;
},
message: 'To must be greater than or equals From.'
}
});
And here is the field defintion:
{field:'FROM',title:'From',width:70, editor:{
type:"validatebox",
options:{
validType:"from[]"
}
}},
{field:'TO',title:'To',width:70, editor:{
type:"validatebox",
options:{
validType:"to[]"
}
}},
The code is working fine, but I think it can be much easier, with a row validator perhaps?
If yes, can u give me simple example ?
And i don't like this lines here:
var ed2 = $('#Tolerances_grid').datagrid('getEditor', {index:my_single_update_index,field:'FROM'});
var from_value = $(ed2.target).val()
I wonder, why i can't use the action getValue() from the editor to get value?
Any ideas?
Thanks.