Text field extension with button in ExtJs
How do I crate a special Ext.form.TextField with a button. When the user clicks on it it 开发者_如何转开发will show a list of of items to choose from. When something is selected it will come back to the parent form populating the form with selected item.
You have just perfectly described a ComboBox so you may want to look into using that instead:
http://dev.sencha.com/deploy/dev/docs/?class=Ext.form.ComboBox
If you still want a button next to a TextField, however, then you can use a CompositeField:
http://dev.sencha.com/deploy/dev/docs/?class=Ext.form.CompositeField
var MyField = new Ext.form.TextField({
name: 'my_field',
flex: 1
});
new Ext.form.CompositeField({
fieldLabel: 'My field',
items: [
MyField,
{
xtype: 'button',
text: 'Choose item'
handler: function() {
// Show a menu or selection dialog, then set the user's
// selected value with:
MyField.setValue(value);
}
}
]
});
精彩评论