There is a simple sample with column validation:
function requiredFieldValidator(value) {
if (value == null || value == undefined || !value.length)
This was very helpful. I am creating different input types for every type of possible entry - email, phone, zip and so forth. To do this with JSON, you have to modify your slick.grid.js file to evaluate the entries to make them an object call.
if (d) {
if(m.formatter){
m.formatter=eval(m.formatter)
} // make it an object call instead of string
if(m.editor) {
m.editor=eval(m.editor)
}
if(m.editorOptions) {
m.editorOptions=eval(m.editorOptions)
}
}
Make your JSON columns have this update:
\"editor\": \"Slick.Editors.Conditional\",
\"editorOptions\":
{\"pattern\":\"email\", \"msg\":\"Must be a valid email\", \"required\":\"1\"}
Make youre slick.editors.js look like this:
(function ($) {
$.extend(true, window, {
"Slick": {
"Editors": {
"Conditional": Conditional,
inside -> function Conditional(args){
if(typeof condObj.pattern != 'undefined') {
if(condObj.pattern=='email'){
pattern=/^([0-9a-zA-Z]+([_.-]?[0-9a-zA-Z]+)*@[0-9a-zA-Z]+[0-9,a-z,A-Z,.,-]*(.){1}[a-zA-Z]{2,4})+$/;
val=$input.val();
if(pattern.test(val) != true && val!='') {
returnMsg = (condObj.msg) ? condObj.msg : "Value is invalid";
returnValid = false;
}
}
}
if(!returnValid){
alert(returnMsg)
}