Combobox autoSize to item width
Is there a way of setting the spark ComboBox component width to fit it's labels? I am attempting to get the component to be a snug fit to its longest item label.
Thanks in advance.
ComboBox does not automatically size itself to fit the largest item in its dataProvider. The closest you can come to this behavior is to use typicalItem to set the size of ComboBox based on a known object.
Similar Messages
-
Update ComboBox model / change items
Hi, ive hit a wall here can someone give me a leg up?
I have two JComboBoxes
I want selections in the first to change the items in the second.
i.e
I want to register the firsts ItemListener to change the seconds ComboBoxModel
im trying to use
myCombo2.setModel( X )
is there anyway to convert an String[] to a ComboBoxModel so i can fit it in X?
I origionally drew my ComboBoxes by passing String[] arrays to the constructors.
If i make a new ComboBox when the items change i have to re add it to the panel and draw the whole frame again, is that right?
thanks all
:)Thanks for the guidance!
It seems understanding the API docs is really usefull... DUH
well im getting better
in the end i solved this by
class whatever(){
private DefaultComboBoxModel model;
private void createProdTypeCombo()
model = new DefaultComboBoxModel();
prodTypeCombo.setModel(model);
private void createProductCombo()
productCombo = new JComboBox((events.doQuery(
"SELECT item FROM Products Group By item ", 1)).toArray(new String[0]));
productCombo.addActionListener(
new ActionListener()
@Override
public void actionPerformed(ActionEvent e) {
//updates the model for the second combo box
prodTypeCombo.removeAllItems();
ArrayList<String> results = new ArrayList<String>();
String selectedItem = (String)productCombo.getSelectedItem();
results = events.doQuery("SELECT type FROM Products where " +
"item= '" + selectedItem + "' group by type", 1);
Object[] resultsOK = results.toArray();
or (int i=0; i<results.size(); i++ )
model.addElement(resultsOK);
Thanks all! -
I have a Combobox with 4 items. When it�s closed
you can see the item with index 0. If I open the
ComboBox, I want to see all elements except thatone
with index 0. This should only be seen in the normal
closed Combobox field and not in the opened, too.
Has someone a model or a renderer
for that problem. It�s very urgent.
Thanx and regards
StephanI tried it, after des FocusGained Event,
but it doesn�t work that way:
private void jComboBox1FocusGained(java.awt.event.FocusEvent evt) {
jComboBox1.setSelectedItem(null);
regards
Stephan -
DataGrid Combobox dataprovider erasing items
I have a DataGrid that is linked to an array of custom data objects which I call a seriesList. You are supposed to be able to choose the name of each series via a combobox in the datagrid. It works fine except when the user selects the combobox and then clicks somewhere else in the interface, which closes the combobox and erases whichever item is previously selected!
<!-- Definition in application -->
<!-- axis.seriesList is and ArrayCollection of actionscript objects called SeriesObjects which have a var name:String variable -->
<mx:DataGrid id="seriesTable" color="black" fontSize="9" rowHeight="30" editable="true" resizeEffect="slow" rollOverColor="#CCCCCC"
selectionColor="#999999" dataProvider="{axis.seriesList}" width="100%"
rowCount="{axis.seriesList.length > 2 ? axis.seriesList.length : 2}" >
<mx:columns>
<mx:DataGridColumn dataField="name" headerText="Name" width="280" headerStyleName="centered" id="nameColumn"
rendererIsEditor="true" editorDataField="result" itemRenderer="renderer.SeriesBoxRenderer"/>
</mx:columns>
</mx:DataGrid>
<!-- SeriesBoxRenderer -->
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" horizontalAlign="center">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
// Define a property for returning the new value to the cell.
public var result:String="";
[Bindable]
private var dpValue:ArrayCollection;
private function init():void {
// list of possible names to choose from for this series
dpValue = mx.core.Application.application.seriesArray;
// Override the set method for the data property.
override public function set data(value:Object):void {
if (dpValue == null) init();
super.data = value;
if (value != null) {
var currentValue:String = value.name;
var len:int = dpValue.length;
for (var i:int = 0; i < len; i++) {
if (dpValue[i].name == currentValue) {
editor.selectedIndex = i;
return;
editor.selectedIndex = 0; }
public function onChange():void {
var index:int = editor.selectedIndex;
result = dpValue[index].name;
data.name = dpValue[index].name;
]]>
</mx:Script>
<mx:ComboBox id="editor" textAlign="left" labelField="name" dataProvider="{dpValue}" change="onChange()"/>
</mx:VBox>I'm thinking the problem may be the dataprovider for the combobox. This array is also shared with another List component in another tab on the interface. The reason I am thinking this is because I have another item renderer which uses a combobox and does not erase itself when you click nothing. Here is the code for that item, and the only difference I can see between this code and the code that doesn't work is the fact that the dataprovider is shared with another part of the code. Still not sure how to fix this, however.
[Bindable]
private var dpValue:ArrayCollection;
private function init():void {
dpValue = mx.core.Application.application.aquisitionOptions.lastResult.system.data;
for ( var i:int=0; i<dpValue.length; i++ ) { //loop over the items in the dataProvider
if (dpValue[i].id == data.aquisitionID) { //compare desired value to current item.data value
editor.selectedIndex = i; //set the seletedIndex of the combo box
data.aquisitionDescr = dpValue[i].name;
break;
// Override the set method for the data property.
override public function set data(value:Object):void {
super.data = value;
if (dpValue == null) init();
if (value != null) {
var currentValue:String = value.aquisitionDescr;
trace ("\n current: ", currentValue);
var len:int = dpValue.length;
for (var i:int = 0; i < len; i++) {
if (dpValue[i].name == currentValue) {
editor.selectedIndex = i;
return;
editor.selectedIndex = 0;
public function onChange():void {
var index:int = editor.selectedIndex;
result = dpValue[index].name;
data.aquisitionDescr = dpValue[index].name;
data.aquisitionID = editor.selectedItem.id as String;
]]>
</mx:Script>
<mx:ComboBox id="editor" labelField="name" dataProvider="{dpValue}" change="onChange()"/>
<!-- definition in the datagrid -->
<mx:DataGridColumn dataField="aquisitionDescr" headerText="Data Aquisition" width="160" headerStyleName="centered" id="acquisitionColumn"
rendererIsEditor="true" editorDataField="result" itemRenderer="renderer.AquisitionBoxRenderer"/> -
Combobox as Datagrid Item editor
Hi there, i'm trying to use a combobox as an itemEditor for a datagridcolumn, and i'm having some difficulties in doing this.
I'm using the code below to define the column, so far so good the itemeditor appears and selects the item accordingly to the value of the datafield.
My problem is, if I open the combobox and do not choose none of the items, the value that passes to the datagrid is 0, but i want to pass the old value. So that the value remains the same.
the dataprodiver for the combobox is this one (rows from database)
id description
1 xxxxx
2 yyyyy
the datafield banda_horaria_id holds an integer witch match one of the values above.
Can anyone help me, and tell me what should i do to maintain the value if none of the combobox items is selected.
Thanks in advance.
PlumbSoldier
<mx:DataGridColumn headerText="Banda Horária" dataField="banda_horaria_id" id="bandaHoraria"
rendererIsEditor="false" editorDataField="selectedItem" >
<mx:itemEditor>
<mx:Component>
<mx:ComboBox initialize="outerDocument.cbBandaHoraria(event)"
fontWeight="normal" labelField="descricao" >
<mx:Script>
<![CDATA[
import mx.controls.DataGrid;
private var columnDataField:String;
private var dtGrid:DataGrid;
override public function set data(value:Object):void
dtGrid=listData.owner as DataGrid;
columnDataField=dtGrid.columns[listData.columnIndex].dataField;
super.data = value;
if (value != null)
var len:int = this.dataProvider.length;
for (var i:int = 0; i < len; i++)
if (this.dataProvider[i].id == value[columnDataField])
this.selectedIndex = i;
break;
public function onChange():void
var index:int = this.selectedIndex;
if (index !=-1){
id = this.dataProvider[index].id;
} else{
var len:int = this.dataProvider.length;
for (var i:int = 0; i < len; i++)
if (this.dataProvider[i].id == data[columnDataField])
this.selectedIndex = i;
break;
]]>
</mx:Script>
</mx:ComboBox>
</mx:Component>
</mx:itemEditor>
</mx:DataGridColumn>Thanks for your help rgadiparthi , but that didn't helped me.
But i managed to solve my problem. -
Table (analysis item) Width - In WAD
Hi All,
has someone been able to change the width of the analysis item in WAD? I do whatever I can and the table width is still the same..
I particulary want to use full_width parametr.... so using module com.sap.ip.bi.rig.ColumnWidth is not really solution for me....
Am I missing something, or is that a bug?
Many thanks for any hints!!!
Regards
PavelHi Priya,
thanks for answer.... The table seems OK, so everthing is displayed correctly.... see pics
[http://www.screencast.com/users/pavel.rais/folders/SAP/media/9da56465-4a54-4589-8674-ba05f1456cba]
But when I change width of table or chech full_width parameter, it stays the same and I need it to be broader....
(I am using structers in my reports... so not sure if Paging could change something, I tried to change all the parameters anyway, but without any results....:-))
Any Ideas?
Thanks!
Pavel -
Hello.
Is there any way to increase the default width of the shuttle item? Both the left and the right windows seem to be about 20 chars wide by default. The item's element height seems to be working - I can change it. But the item's element width value does not seem to matter.
Thanks
BorisIn the HTML Form Element Attributes put this:
style="width:200px"
and it will increase the width of each side of the shuttle to that size.
Denes Kubicek
http://deneskubicek.blogspot.com/
http://www.opal-consulting.de/training
http://apex.oracle.com/pls/otn/f?p=31517:1
------------------------------------------------------------------- -
Hi All, can anyone tell what controls the width that input text items are rendered in an html region?
I have defined the width as 15 in the elements properties section in the item definition, the item is rendered a different width on different pc's.
I also noticed that the font that is used for input text is bigger on the pc's that render the item bigger. Are these 2 things related?
Can anyone tell me where the font used (and size) is set?
Thanks in advance
FintanFintan Stack wrote:
Hi All, can anyone tell what controls the width that input text items are rendered in an html region?
I have defined the width as 15 in the elements properties section in the item definition, the item is rendered a different width on different pc's.
I also noticed that the font that is used for input text is bigger on the pc's that render the item bigger. Are these 2 things related?Yes. This is caused by different local font settings at browser level. The size of the form control is relative to the element width at the locally-defined browser font size.
Can anyone tell me where the font used (and size) is set?The presentational aspects of APEX applications are controlled using a combination of HTML and CSS via themes and templates. Base font sizes will typically be set in theme CSS by specifying the CSS <tt>font-size</tt> property for the page <tt>body</tt> element (or more problematically using the universal selector).
If you want the form controls rendered at the same size irrespective of local font settings, specify an absolute width using CSS in the HTML Form Element Attributes:
style="width: 200px;"However, for accessibility and usability reasons I wouldn't recommend this: users should have the ability to control the font size locally so they can read it comfortably, and controls should be rendered relative to this. -
Is there a way to increase Apex 3.0's Shuttle Item's width? I've tried changing the width propery of the Element, the Element's HTML Table Cell Attributes, HTML Form Element Attributes and Form Element Option Attributes all to no avail.
thanksHi Kathryn,
setting "HTML Form Element Attributes" to
style="width: 300px;"also works. It has the advantage that you can have different sizes when you have multiple shuttles.
Patrick
My APEX Blog: http://inside-apex.blogspot.com
The ApexLib Framework: http://apexlib.sourceforge.net
The APEX Builder Plugin: http://sourceforge.net/projects/apexplugin/ -
Custom Font On Individual Row Items In A ComboBox Component
Hello everyone,
I am new to flash and I have spent many hours trying to get a
particular piece of functionality to work. I am trying to create a
combobox where the items listed in the combobox are font names and
each item will display using the font of the item label. For
instance, one item label in the list is "New Times Roman" and I
want that particular row in the combobox to have the text AND font
of "New Times Roman". For some reason, inside of my custom
CellRenderer class, I cannot seem to find a way to get the item
label that corresponds to the CellRenderer and the
CellRenderer.data item always appears to be null!
Please help. Thank you in advance for any help you can
provide.
This is the code I am currently using:
//From the main class, I am creating an instance of the
CustomizableComboBox and adding in the font names I am interested
in.
var comboFont:CustomizableComboBox=new
CustomizableComboBox();
comboFont.width=200;
comboFont.height=30;
comboFont.addItem({label:"Arial", data:"Arial"});
comboFont.addItem({label:"Times New Roman", data:"Times New
Roman"});
comboFont.addItem({label:"Tahoma", data:"Tahoma"});
comboFont.addItem({label:"Verda", data:"Verda"});
comboFont.addItem({label:"Wide Latin", data:"Wide Latin"});
comboFont.addItem({label:"Monotype Corsiva", data:"Monotype
Corsiva"});
comboFont.addItem({label:"Trebuchet MS", data:"Trebuchet
MS"});
comboFont.addItem({label:"Alba", data:"Alba"});
comboFont.addItem({label:"Arial Black", data:"Arial Black"});
comboFont.selectedIndex=1;//Times New Roman by default.
addChild(comboFont);
//In the CustomComboBox.as file, I have the CustomComboBox
class defined as:
package {
import fl.controls.ComboBox;
import flash.text.TextFormat;
import flash.events.Event;
public class CustomizableComboBox extends ComboBox{
public function CustomizableComboBox(){
super();
dropdown.setStyle("cellRenderer",CustomCellRenderer);
addEventListener(Event.CHANGE,changeIndex);
//Changes the text displayed as the currently selected item
with its corresponding font.
private function changeIndex(event:Event):void {
var fontName:String=selectedItem.label;
var format:TextFormat=new TextFormat(fontName,16);
setStyle("textFormat",format);
//Finally, in the CustomCellRederer.as file, I have defined
the CustomCellRenderer class as:
package{
import fl.controls.listClasses.CellRenderer;
import flash.text.TextFormat;
import fl.controls.ComboBox;
public class CustomCellRenderer extends CellRenderer{
public function CustomCellRenderer(){
//The trace will show that the data for the custom
cellrenderer is always null!!!
trace('custom cell data = '+data);
//If I could just get the item label corresponding to the
CellRenderer for this
//cell, then I could set the font as I desire.
var fontName:String="Wide Latin";
var format:TextFormat = new TextFormat(fontName,16);
setStyle("textFormat", format);
}Oh, sorry. I see now what you want to do. Hmmm...
I cannot find any references to the class that defines each
item in the box. Off the top of my head what I would do (besides
writing my own combobox :-) - I would add some event listener with
capture set to true that would listen to the input text field
change Event.CHANGE and set ComboBox.editable = true. So, when you
type something in the item - it will dispatch event. By reading
Event.target, you may figure out what object is the TextField you
want to chage the style for. After that it may be possible just to
change style for each individual item's TextField.
myComboBox.editable = true;
myComboBox.addEventListener(Event.CHANGE, changeHandler);
private function changeHandler(e:Event):void{
trace(e.target + " : " + e.currentTarget);
Just a thought... -
Combobox Items vanishing?
I have a problem with ComboBox selection. Items above the last selected seem to be vanishing from the list. I'll show my xaml and then explain:
<ComboBox x:Name="cmbFirmness" HorizontalAlignment="Left" Margin="86,106,0,0" VerticalAlignment="Top" Width="227" SelectionChanged="cmbFirmness_SelectionChanged" Grid.ColumnSpan="2">
<x:String>Soft</x:String>
<x:String>Medium</x:String>
<x:String>Hard</x:String>
</ComboBox>
So, for example, if I select 'Medium' from the list, then open the list again, I can only see 'Medium' and 'Hard'.
If I select 'Hard' then open the list again, I can only see 'Hard'. It's like the other options have vanished, or can't be scrolled to.
Thanks in advance for any help you can offer.Hi L61,
Well Done!
I am very glad that you have solved your problem by yourself, if you have any other questions welcome to post it in this forum.
Best Regards,
Amy Peng
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Checkboxes as items in the combobox
Hi, Anybody knows how i can use the checkboxes in the combobox as the items.
And this code illustrates how to do it:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.events.FlexEvent;
import mx.collections.ArrayCollection;
import mx.controls.CheckBox;
[Bindable] private var ac:ArrayCollection = new ArrayCollection([
{label: "one", selected: false},
{label: "two", selected: false},
{label: "three", selected: false},
{label: "four", selected: false}
public function saveCheckState(evt:Event):void{
var dataProviderItem:Object = ac.getItemAt(ac.getItemIndex(cbx.selectedItem));
dataProviderItem.selected = CheckBox(evt.currentTarget).selected;
ac.setItemAt(dataProviderItem, ac.getItemIndex(cbx.selectedItem));
for each(var obj:Object in ac){
for(var key:String in obj){
trace(key + " : " + obj[key]);
trace("******************************");
]]>
</mx:Script>
<mx:ComboBox id="cbx" dataProvider="{ac}" labelField="label" width="120">
<mx:itemRenderer>
<mx:Component>
<mx:HBox width="100%">
<mx:Label text="{data.label}"/>
<mx:Spacer width="100%"/>
<mx:CheckBox id="check" selected="{data.selected}"
change="outerDocument.saveCheckState(event);"/>
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:ComboBox>
</mx:Application>
If this post answered your question or helped, please mark it as such. -
I have Table and a textfield as only two UI components.
For the table i am using my custom editor(NewComboEditor.java), for this i am extending the "DefaultCellEditor" and applying this editor for my jTables first column. My custom editor simply prepares the editor by instantiating the jCombobox and sets the selected value and return it (in overwridden "getTableCellEditorComponent" method).
I have made my combobox editable by setting "combobox.setEditable(true)" in constructor of editor while creating the instance of combobox.
Now everything works fine except whenever i tried to select an item from the combobox , after the item selection, focus is assigned to textfield which is the nextfocusable component to jTable on which the comboboxes are rendered.
If my jcomboboxes are not editable then selection remains on combobox only.
The implemetation for the comboEditor and comboRenderer is as follows.
=========================== Main frame having all compenents =================================
public class CreateAndShowComboBoxes extends JFrame {
protected JTable table;
* Default constructor..
public CreateAndShowComboBoxes() {
Container pane = getContentPane();
pane.setLayout(new BorderLayout());
//create table model, this table model extends AbstractTableModel.
MyTableModel tableModel = new MyTableModel();
table = new JTable(tableModel);
TableColumnModel tcm = table.getColumnModel();
TableColumn tc = tcm.getColumn(MyTableModel.LAST_NAME);//set to column 1.
//specify the renderer and editor.
tc.setCellRenderer(new ComboRenderer());
tc.setCellEditor(new NewComboEditor());
JScrollPane jsp = new JScrollPane(table);
pane.add(jsp, BorderLayout.CENTER);
JTextField textField = new JTextField();
table.setNextFocusableComponent(textField);
pane.add(textField, BorderLayout.SOUTH);
* Create a frame and make it visible.
public static void main(String[] args) {
CreateAndShowComboBoxes stt = new CreateAndShowComboBoxes();
stt.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
stt.setSize(400, 300);
stt.setVisible(true);
============================================ComboEditor =========================================
public class NewComboEditor extends DefaultCellEditor{
*Default constructor.
public NewComboEditor() {
super(getComboBox());
JComboBox combobox = (JComboBox)getComponent();
combobox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//fireEditingStopped();
//stopCellEditing();
* Override to invoke setValue on the formatted text field.
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected,
int row, int column) {
JComboBox cb = (JComboBox)super.getTableCellEditorComponent
( table, value, isSelected, row, column);
cb.setSelectedItem(value);
return cb;
* @return object
public Object getCellEditorValue() {
JComboBox cb = (JComboBox)getComponent();
Object o = cb.getSelectedItem();
return o;
* @return true
public boolean stopCellEditing(){
JComboBox cb = (JComboBox)getComponent();
cb.requestFocus(true);
return super.stopCellEditing();
* @return combobox instance
public static JComboBox getComboBox(){
JComboBox combobox = new JComboBox();
combobox.setEditable(true);
combobox.addItem("khan");
combobox.addItem("rawal");
combobox.addItem("shetti");
combobox.addItem("more");
combobox.addItem("sohel");
combobox.addItem("kambli");
combobox.addItem("warne");
return combobox;
========================================= ComboRenderer ====================================
public class ComboRenderer extends JComboBox implements TableCellRenderer {
*Default constructor.
public ComboRenderer(){
super();
addItem("khan");
addItem("rawal");
addItem("shetti");
addItem("more");
addItem("sohel");
addItem("kambli");
addItem("warne");
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
setSelectedItem(value);
return this;
======================================================================================Message was edited by:
yuvi
Message was edited by:
yuviHi Pravin Ghadge,
Please Use this code for focus.
oMat.Columns.Item("Column_UID").Cells.Item(oMat.VisualRowCount).Click(SAPbouiCOM.BoCellClickType.ct_Regular)
I hope it will work.
Thanks,
P.T.Sampath. -
Custom itemRenderer in a F3 ComboBox on specific list items after combobox creation
Hi,
I'm trying to set a specific list item in a mx combobox to have a custom item renderer, the problem is that I cannot do this via mxml, it needs to be done via actionscript at a later stage, eg: combobox gets created, combobox gets populated, user does other tasks, combobox needs to set one or more items in the combobox to have icons (via item renderer)..
I can do this via the onChange event, but it only applies the icon when the combobox is opened and there is a slight delay so you can see the icon being added.
Thanks in advance for any help
JHi,
If I understand correctly, you can create you comboBox with all items at the begining:
http://blog.flexexamples.com/2007/08/18/displaying-icons-in-a-flex-combobox-control/
After that, base on user task, you can filter you comboBox:
http://blog.flexexamples.com/2008/03/12/using-a-combobox-to-filter-items-in-a-datagrid-in- flex/
In this way you don't see the delay.
Johnny
Please rate answers. -
Remember selected item with ComboBox
Hey All,
I was just wondering how other pople solve this issue.
I have a combobox with a XX number of items in there. Now
when I re-populate the combobox the selected item get's lost. I
also would like to remember the selected item during sessions. For
instance when A user selected item XX on monday. I would like to
have it automatically set XX again when a user comes back on
tuesday.
Is there a meganism in adobe flex that allows me to remember
a 'state' of a object, or is that custom programming?
Ideally I would like to have a component that can do teh work
for me rather then my application handles the logic, some sort of a
state manager?
RiesUse a SharedObject, and write to it in the ComboBox change
handler. See SharedObject in FB3 help sys.
Maybe you are looking for
-
APEX Listener 2.0 - RESTful Services Failure with 404 - Not Found
Versions used: * APEX Listener 2.0.0.354.17.05 * Application Express 4.2.1.00.08 * Oracle Database 11.2.0.1 When testing the sample RESTful Service Module oracle.example.hr I always get 404 - Not Found page. I followed the documentation to install an
-
Unable to load data into Planning cube
Hi, I am trying to load data into a planning cube using a DTP. But the system throws a message saying that, real time data loading cannot be performed to the planning cube. What would be the possible reason for the same? Thanks & Regards, Surjit P
-
Coherence, OSB and SOA integration
Hi, I have a WL domain, that consists on a SOA cluster and a OSB cluster. I want to have external cache servers, as it is the preferred option provided by Oracle, so I have external processes which starts a cache, loads data from database, and create
-
Hi I am trying to find the best way to migrate from ESXi to Hyper-V with Server 2003 DC with two hard drives. I know I should not snapshot the DC so I guess what's the best way to do this. Here is the one catch I only have on physical host. Should I
-
N97 Sending Videos & Satellite Maps
Hi All Has anybody noticed that you cant send videos from the Videos & Tv Library by any means on the N97, the only way I can see a way round it is to use the file manager which is a pain! Also when you download maps via pc to the phone the map data