PDA

View Full Version : Changing TextField.maxLength On The Fly



jurban
26 Feb 2009, 7:42 AM
I have and EditorGridPanel. Column one contains a dropdown. Depending on which value is chosen in the dropdown I need to set the maxLength attribute of the TextField editor in the second column. I do not see any method or public property in TextField at looks like it will enable me to do this. Any ideas how I could do this?

Thanks!

mjlecomte
26 Feb 2009, 8:01 AM
That only does validation you realize, not limit how many characters it will allow to be typed in.

Looks like you just need to access the editor and set the property.


myEditor.maxLength = 25;

So store a reference in some way.

jurban
26 Feb 2009, 10:03 AM
That only does validation you realize, not limit how many characters it will allow to be typed in.

Looks like you just need to access the editor and set the property.


myEditor.maxLength = 25;So store a reference in some way.
I tried var myEditor = cm.getCellEditor(col, row)
myEditor.maxLength = x
but the editor of the cell still has the maxLength the columnmodel specified.

mjlecomte
26 Feb 2009, 10:08 AM
I created a reference before specifying it in the column model. I don't know that what you did is accessing the same object or not.

mjlecomte
26 Feb 2009, 10:16 AM
I created a reference before specifying it in the column model. I don't know that what you did is accessing the same object or not.

I just checked, they are not the same object.

jurban
26 Feb 2009, 11:43 AM
Ok, I instantiated the editor and passed the instance to the column model. Then I referenced the instance of the editor directly and was able to change the maxLength on the fly.

It would be interesting if a ExtJS developer would comment on what cm.getCellEditor(col, row) returns.