[#384,sclickgrid][s] add field validator bind to field.format
This commit is contained in:
@@ -99,6 +99,19 @@ my.SlickGrid = Backbone.View.extend({
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// we need to be sure that user is entering a valid input , for exemple if
|
||||||
|
// field is date type and field.format ='YY-MM-DD', we sould be sure that
|
||||||
|
// user enter a correct value
|
||||||
|
var validator = function(field){
|
||||||
|
return function(value){
|
||||||
|
if(field.type == "date" && isNaN(Date.parse(value))){
|
||||||
|
return {valid: false, msg: "This format is required" + field.type};
|
||||||
|
}else {
|
||||||
|
return {valid: true, msg :null }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
_.each(this.model.fields.toJSON(),function(field){
|
_.each(this.model.fields.toJSON(),function(field){
|
||||||
var column = {
|
var column = {
|
||||||
id: field.id,
|
id: field.id,
|
||||||
@@ -106,7 +119,8 @@ my.SlickGrid = Backbone.View.extend({
|
|||||||
field: field.id,
|
field: field.id,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
minWidth: 80,
|
minWidth: 80,
|
||||||
formatter: formatter
|
formatter: formatter,
|
||||||
|
validator:validator
|
||||||
};
|
};
|
||||||
|
|
||||||
var widthInfo = _.find(self.state.get('columnsWidth'),function(c){return c.column === field.id;});
|
var widthInfo = _.find(self.state.get('columnsWidth'),function(c){return c.column === field.id;});
|
||||||
|
|||||||
Reference in New Issue
Block a user