I have this function that I can call via a button, but I would like to implement this as a cell validation when the date is entered into the TO column of my grid.
Code:
function checkDates() {
var confirm = true;
mygridDates.forEachRow(function (id) {
var val1 = mygridDates.cells(id, 1).getValue();
var val2 = mygridDates.cells(id, 2).getValue();
if (val1 >= val2)
confirm = false;
})
}
What I would like to do:
//Dates Grid
mygridDates = new dhtmlXGridObject(‘mygrid_Dates’);
mygridDates.setImagePath(“Scripts/dhtmlxGrid/codebase/imgs/”);
mygridDates.setHeader(“ID,From,To”);
mygridDates.setInitWidths(“75,200,200”);
mygridDates.setColAlign(“center,center,center”);
mygridDates.setColTypes(“ro,dhxCalendarA,dhxCalendarA”);
mygridDates.enableValidation(true, true, true);
mygridDates.setColValidators(“NotEmpty,NotEmpty,checkDates”);
mygridDates.setSkin(“light”);
mygridDates.attachEvent(“onValidationError”, function (id, ind, value) {
mygridDates.setCellTextStyle(id, ind, “font-weight:bold;”);
document.getElementById(‘message’).innerHTML = “Error at cell (” + id + “,” + ind + "), value must " + (ind == 0 ? “not be empty” : “be a valid date”);
return false;
});
mygridDates.attachEvent(“onValidationCorrect”, function (id, ind, value) {
mygridDates.setCellTextStyle(id, ind, “”);
document.getElementById(‘message’).innerHTML = “”;
return false;
});
mygridDates.init();
mygridDates.enableAutoHeight(true);
Any help would be appreciated.