I have a page whit a few DHTMLX Grids and i need the most of the functions in each grid. So i have created a gridFunction.js and include it in each header. This works fine in Firefox but IE makes trouble when i want to use a event that is stored in my external gridFunction.js.
mygrid.attachEvent(“onEditCell”,validateEntry);
// gridFunction.js
-------------------------
// check the new entry for errors
function validateEntry(stage,rowId,cellIndex,newValue,oldValue){
// test if a entry is longer then the maximum of the database field
if ((stage==2) && newValue.length > getMaxFieldLength(cellIndex)) {
mygrid.cells(rowId,cellIndex).setBgColor(errorColor);
mygrid.clearSelection();
alert(“Your entry is to long, only " + getMaxFieldLength(cellIndex) + " characters are allowed in this field”);
}
// test if a mendatory field is empty
else if((stage==2) && in_array(cellIndex,mandatoryFields) && newValue==""){
mygrid.cells(rowId,cellIndex).setBgColor(errorColor);
mygrid.clearSelection();
alert(“This field can not be empty!”);
}
else {
mygrid.cells(rowId,cellIndex).setBgColor(""); // set color back to normal if everything is ok
}
return true;
}
IE shows this error: ‘validateEntry’ is undefined, but in Firefox works everything well. Any idea how i can solve that whit out copy this function to every grid separately?
thanks,
Bruno
In which order you are including js files on the page?
Please be sure that gridFunction.js included before attachEvent command executed and related script tag has not “defer” attribute