View Full Version : ComboBox with button on the right
francescoNemesi
3 May 2007, 6:23 AM
Hello,
I have a simple form with a ComboBox defined as per the code below. All is well, apart from the fact that the button is added underneath the combobox justified in the middle of the form container div....
What I'd like to do is to have the button immediately to the right and on the same "line" of the combo box for the user to trigger a function when he's satisfied with the selection. Any ideas? (the examples and demos all have buttons below the input fields)
Thanks for your help,
Francesco
========================
var combo = new Ext.form.ComboBox({
fieldLabel: 'Cliente',
name: 'cliente',
store: store,
valueField: 'cclie',
displayField:'cliente',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Seleziona un cliente...',
selectOnFocus:true
});
var selectClientForm = new Ext.form.Form({
labelAlign: 'left'
});
selectClientForm.add(combo);
selectClientForm.addButton('ok');
selectClientForm.render('select-client-form-div');
tryanDLS
3 May 2007, 7:35 AM
You could do like the dynamic form (form 2) example does and put each one in a column container. Or, if you didn't want to do that, you could look at adding some css to float the the containing divs.
francescoNemesi
3 May 2007, 8:32 AM
Thanks for your reply.
I already tried to use the "columns", but I couldn't quite work it out...
How would you use the "floating" trick?
Thanks again, Kind Regards
Francesco
My code below... I get this error:
==============================
el has no properties
DomHelper("beforeend", null, "<table border="0" cellpadding="0" cellspacing="0" class="x-btn-wrap"><tbody><tr><td class="x-btn-lef...")ext-all.js (line 9)
Template(null, [" "], true)ext-all.js (line 11)
Button("ok")ext-all.js (line 111)
Button("ok", function())ext-all.js (line 111)
init()main.js (line 94)
Observable()ext-all.js (line 15)
EventManager()ext-all.js (line 17)
[Break on this error] Ext.DomHelper=function(){var _1=null;var _2=/^(?:br|frame|hr|img|input|link|meta...
======================================
var button = new Ext.Button('ok',function(){
var cliForm = document.getElementById(selectClientForm.id);
createXmlTree('tree-div-intestatario',
'/azimut/BuildXmlTree?cl='+cliForm.cliente.value,
function(){
this.render();
this.getRootNode().expand();
});
});
var selectClientForm = new Ext.form.Form({
labelAlign: 'left'
});
selectClientForm.column(
{width:300},
combo
);
selectClientForm.column(
{width:300, clear:true},
button
);
selectClientForm.render('select-client-form-div');
jay@moduscreate.com
4 May 2007, 9:37 AM
can you do all of us a favor and post your code inside of php tags?
jsakalos
4 May 2007, 9:45 AM
I agree. I would consider posting code inside php or code tags as good manners on this forum.
francescoNemesi
6 May 2007, 11:48 PM
Sorry about that... will do next time.
Thanks
francescoNemesi
21 May 2007, 5:11 AM
Just to let you know, I managed to find a workaround for this problem by using a toolbar with the combo box and a button in it. It's not the perfect/ideal solution, but still it delivers...
It would be ideal to have a better handling of element positioning in a future version. It would make a fantastic framework even better!
I Hope the code below will be useful to others.
Francesco
var combo = new Ext.form.ComboBox({
fieldLabel: 'Cliente',
name: 'cliente',
store: store,
valueField: 'cclie',
displayField:'cliente',
typeAhead: true,
mode: 'local',
loadingText: 'Caricamento clienti...',
triggerAction: 'all',
emptyText:'Selezioni un cliente...',
maxHeight: 200,
selectOnFocus:true
});
function onButtonClick(btn){
Ext.MessageBox.show({
title: 'Click Handler',
msg:'Clicked!',
buttons: Ext.MessageBox.OK
});
}
var tb = new Ext.Toolbar('north-toolbar');
tb.addField(combo);
tb.add(' ',{
handler : onButtonClick,
icon: 'images/refresh.gif',
cls: 'x-btn-text-icon',
text: 'Seleziona nuovi clienti',
tooltip: "<b>Seleziona un nuovo gruppo di clienti</b><br/>Reinizializza l'area di lavoro per selezionare<br/> un nuovo gruppo di clienti."
},'-');
dam1an
24 Jun 2007, 12:17 PM
Hi Francesco,
what is 'north-toolbar' in your html?
Is it a div and if so where is it placed? I can't quite seem to get your solution to work.
Thanks,
Damian
cfulnecky
18 Jul 2007, 3:15 PM
Any possibility of replacing the comboBox trigger with a splitButton?
cfulnecky
19 Jul 2007, 7:29 AM
Any possibility of replacing the comboBox trigger with a splitButton?
The (now deprecated?) TwinTriggerField example points to a better solution IMHO. See "Search box with 3 triggers (http://extjs.com/forum/showthread.php?p=47666)" for an example.
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.