Setting the maxlength in the Dhtmlx cell Editor

Please suggest if there is some flaw in the following code and whether it works for setting the dhtmlx equivalent of the html attribute maxlength to limit the characters entered in a cell. Not sure this is valid, but please correct the below code so that to set the html attribute maxlength can be set in this way.

Code:

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

please check - viewtopic.php?f=5&t=17655