Dhtmlx equivalent of MaxLength for a cell

In html , To limit the number of characters a user can type into input fields, we use the attribute maxlength.


So, the user cannot enter more than 5 charcters in the input text area.

What is the dhtmlx equivalent of the html attribute maxlength, so that the user cannot enter more than 5 characters in the input editable cell inside the dhtmlxgrid.
Please Help

What is the dhtmlx equivalent of the html attribute maxlength

there is not dhtmlx equivalent for maxlength.

For “ed” columns you may use the following approach:

grid.attachEvent("onEditCell",function(stage,id,index){ if(stage==1&&grid.editor.obj){ grid.editor.obj.onkeypress = function(e){ e = e||window.event; if((e.keyCode >= 47) || (e.keyCode == 0)){ var text=this.value; if(text.length>=15){ return false; } } } } return true })

Thanks for the reply.

Please suggest if there is some flaw in the following code and whether it works for setting the maxlength attribute in an alternative way. Not sure this is valid, but if possible to set the attribute maxlength in this way, it would be good.

var cell = mygrid.editor.cell;
var editor = cell.getElementsByTagName(‘input’)[0]||cell.getElementsByTagName(‘textarea’)[0];
editor.setAttribute(“maxlength”,5); //or any other necessary value

This approach (editor.setAttribute(“maxlength”,5); ) can not be used to set maxlength.

Please tell me is there any other possibility to prevent users from entering more characters in a dhtmlx cell other than key Press detection and Validation.

You may also create a custom excell with thge desired maxlength:

docs.dhtmlx.com/doku.php?id=dhtm … le_excells