Combo box disabled for typing
Is there a way to force the user to select a value from the combo popup,
so that we are sure that the user has no typed a text (which does not exist in the combo values for example) in the combo cell?
JeanLuc
November 13,
Anybody else has an idea?
JeanLuc
November 23,
I also needed this same functionality, i implemented the following
In the source file _cell.js i added the bolded block of code into the edit function, (needs to check if this is a combo control, i didn't need to check this as i wanted the ability to set any edit control readonly).
this.setTimeout(function()
{
var text=editor.element().getElementsByTagName("input")[0];
[b]if (editor.getAttribute("readonly"))
{
text.readOnly=true;
}
else
{
text.readOnly=false;
}[/b]
text.focus();
text.select();
text=null})
Next in the code that creates the grid i added code to set the combo control readonly
var combo = new AW.UI.Combo; // create the combo control
combo.setAttribute("readonly", function(){return true;}); // set the readonly attribute of the combo
...
grid.setEditorTemplate(combo, 1); // where 1 is the index of the cell
What i found initially when trying to achieve this is that the readonly attribute is set on the container span of the cell, which is of course ignored, so adding this code into the source in the edit function, means that when a cell enters edit mode, then the contained control is set to readonly.
Neil
December 13,
Yeah, this is great, but only works when the user has focused the control...
How would you do this for all combos on a page (in a grid or not), even when not focused?
Lucas
December 13,
Well the code i put in above is for the grid, for this to work with any control then the code that checks and sets the readonly attribute would have to be in the toString() method or whatever method renders the particular control
Neil
December 14,
See related post at:
/javascript.forum.9294.3/dropdown-control-instead-of-combo.html
LostInSpace
February 7,