How to set selectedIndex of a DropDownList bound to a DataGrid
Hello I'm a newbie.
Here my problem:
I've two kind of objects, named Persona and Email. Persona has a one to many relation with Email object.
Persona is displayed in a DataGrid.
Cliccking a row (a Persona item), I need to display all related emails in a DropDownList. I also want to display the first email automatically (selectIndex=0).
It works for the first row.
Then, after the first row, I click the second row. It loads the related emails correctly but doesn't not display the first email automatically, I have to click on the dropdwonlist and choose it. If I want to see the first email automatically, I need to click the second row twice. But now, going back to the first row, it loads the related emails, but doesn't display the first one automatically.
Can anyone suggest me where is the problem?
Follows my code:
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" applicationComplete="ps.getPersonas()">
<fx:Script><![CDATA[ import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
import spark.events.IndexChangeEvent;
[Bindable]
private var persone:ArrayCollection = new ArrayCollection();
private function getPersonas_resultHandler(event:ResultEvent):void
persone = event.result as ArrayCollection;
private function aggiornaDropDown(event:MouseEvent):void
Alert.show(dd.selectedIndex.toString());
dd.selectedIndex=0;
dd.dataProvider = dg.selectedItem.emails;
dd.labelField= "address";
]]>
</fx:Script>
<fx:Declarations> <s:RemoteObject id="ps" destination="provaService" endpoint="http://localhost:8400/FlexSpringServer/messagebroker/amf">
<s:method name="getPersonas" result="getPersonas_resultHandler(event)" />
</s:RemoteObject>
</fx:Declarations> <mx:DataGrid x="138" y="126" id="dg" dataProvider="{persone}" click="aggiornaDropDown(event)">
<mx:columns>
<mx:DataGridColumn headerText="ID" dataField="id"/>
<mx:DataGridColumn headerText="Nome" dataField="nome"/>
<mx:DataGridColumn headerText="Cognome" dataField="cognome"/>
</mx:columns>
</mx:DataGrid>
<s:DropDownList x="545" y="201" id="dd"/>
</s:Application>
I also tried to set the selectIndex attribute to 0 inside the DroipDownList tag, but I couldn't solve the problem.
Thank you
Paolo
Hello.
I'm sorry but because I'm a newbie your question is not clear.
I wrote the code already included above and two AS valueobjects related to Persona and Email objects.
No more else.
Do I have to write a "renderer". Could you please clarify your question?
I attach new updates to my code but the problem is not solved.
Thank you
Paolo
<?xml version="1.0" encoding="utf-8"?>
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="
library://ns.adobe.com/flex/spark" xmlns:mx="
library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" applicationComplete="ps.getPersonas()" backgroundColor="#F4F384">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.events.ListEvent;
import mx.rpc.events.ResultEvent;
Bindable]
private var persone:ArrayCollection = new ArrayCollection();[
Bindable]
private var emails:ArrayCollection = new ArrayCollection();
private function aggiornaDropDown(event:Event):void
var persona:Persona = new Persona();persona = dg.selectedItem
as Persona;ps.getPersonaEmails(persona);
private function getEmails_Handler(event:ResultEvent):void
emails = event.result
as ArrayCollection;dd.selectedItem = emails.getItemAt(0); //dd.selectedIndex = 0 also doesn't work
]]>
</fx:Script>
<fx:Declarations>
<s:RemoteObject id="ps" destination="ProvaService" endpoint="http://localhost:8400/FlexSpringServer/messagebroker/amf">
<s:method name="getPersonas"/>
<s:method name="getPersonaEmails" result="getEmails_Handler(event)"/>
</s:RemoteObject>
</fx:Declarations>
<s:Panel x="23" y="42" width="505" height="263" title="Contatti">
<s:controlBarContent>
</s:controlBarContent>
<mx:DataGrid x="42" y="26" id="dg" dataProvider="{ps.getPersonas.lastResult}" click="aggiornaDropDown(event)">
<mx:columns>
<mx:DataGridColumn headerText="ID" dataField="id"/>
<mx:DataGridColumn headerText="Nome" dataField="nome"/>
<mx:DataGridColumn headerText="Cognome" dataField="cognome"/>
</mx:columns>
</mx:DataGrid>
</s:Panel>
<s:Panel x="27" y="321" width="501" height="269" title="Dettagli contatti">
<s:VGroup x="45" y="10" width="200" height="200">
<s:HGroup width="150" height="20">
<s:Label text="Nome:"/>
<s:Label text="{dg.selectedItem.nome}" paddingLeft="23"/>
</s:HGroup>
<s:HGroup x="45" y="36" width="150" height="22">
<s:Label text="Cognome:"/>
<s:Label text="{dg.selectedItem.cognome}"/>
</s:HGroup>
<s:HGroup x="45" y="70" width="200" height="118">
<s:Label text="Emails:" paddingTop="5"/>
<s:DropDownList id="dd" dataProvider="{emails}" labelField="address"/>
</s:HGroup>
</s:VGroup>
</s:Panel>
<s:Label x="65" y="10" text="Rubrica" fontSize="33" fontWeight="bold" color="#162ABF"/></s:Application>
Similar Messages
-
How to set the selectedIndex when dataProvider is an XML object in DropDownList?
dataProvider was an XML object
How to set the selectedIndex when dataProvider is an XML object in DropDownList?
I do this:
<s:DropDownList id="dropDownList" requireSelection="true" selectedIndex="2"
labelField="lastName" dataProvider="{employeeService.lastResult.employees.employee}"/>
But always the first item is selected whatever the value of selectedIndex equals to.if i understand correctly, you want the selectedindex to be 2 when the DropDownList displays.
It might be the case that the dataprovider is being sought after it's already selected its index (as the dataprovider isn't already determined to begin with), so currently it's
- setting the selected index to default
- setting the selected index to 2 (your command)
- getting the dataprovider
- setting the selected index to default
try writing a function to set the DropDownList's selected index after it's received the information, or even just attach it to the employeeService result handler.
for quick testing sake you could just add
<s:DropDownList id="dropDownList" requireSelection="true" updateComplete="dropDownList.selectedIndex = 2"
labelField="lastName" dataProvider="{employeeService.lastResult.employees.employee}"/>
to see if my theory is correct. -
How to set a object value bound to a session to JavaScript variable
In a JSP, I store an object value in a HttpSession and I also write a Javascript function to display something on the screen. I need to use the Javascript function to display the object value which is stored in the session. How to set the object value to variable of the JavaScript function. Thanks.
I write a class JavaScriptHelper to convert the object value to variable of the JavaScript;
1.get the data to a javabean from database;
2.convert the data to variable of the JavaScript as a String ;
3.store the object in a HttpSession or Httprequest ;
4.use in Jsp get the String (variable of the JavaScript )
YourBean bean = (YourBean) request.getAttribute("model");
if (bean != null) out.println(bean .getJsCode())
convert function,(this is only for the matrix):
public static String formatJsCode(Vector vector) {
String sJsCode = "";
//get js head
sJsCode = getJsHeader();
//define js array;
sJsCode += "var data=new Array();\n";
Vector v = null;
String sTemp = "", sLine = "";
for (int i = 0; i < vector.size(); i++) {
v = (Vector) vector.get(i);
sLine = "";
for (int j = 0; j < v.size(); j++) {
sTemp = (String) v.get(j);
//replace " to \"
sTemp = sTemp.replaceAll("\"", "\\\\\\\"");
//escape Html Tag
//sTemp = StringUtil.escapeHTMLTags(sTemp);
//replace \r\n to <br>
sTemp = sTemp.replaceAll("\r\n", "<br>");
if (j != 0)
sLine += ",";
sLine += "\"" + sTemp + "\"";
sJsCode += "data[" + i + "]=new Array(" + sLine + ");\n";
//get js foot
sJsCode += getJsFooter();
return sJsCode;
public static String getJsHeader(){
return "<script language=\"JavaScript\">";
public static String getJsFooter(){
return "</script>";
} -
How to set value in selectOnemenu using binding
hi all.
i have bind htmlSelectOneMenu. it contains some value. I want to set or display a value after a process.
How to change value
i have tried using setValue method of both binding property and value property of htmlSelectOneMenu.
Same issue is with InputTextArea. how to set value in it via code(RowSelectionListener of icefaces)Balaji wrote:
hi all.
i have bind htmlSelectOneMenu. it contains some value. I want to set or display a value after a process.
How to change value
i have tried using setValue method of both binding property and value property of htmlSelectOneMenu.
Same issue is with InputTextArea. how to set value in it via code(RowSelectionListener of icefaces)The html SelectOneMenu is bound to a value of a backing bean. You have to change the value of that backing bean, not the JSF component directly. JSF takes care of updating the model, you shouldn't be touching it unless you know what you are doing. -
How to set a JButton,JTextfield, JLabel in a given location
Hi am designing a login screen and i dont know how to set my JLabels and JButtons on the screen. Can some one pls help
Thanx
Edited by: nadeesha on Oct 2, 2007 2:21 AMnadeesha
If you want to really learn, go to the javaTutorial.
http://java.sun.com/docs/books/tutorial/uiswing/TOC.html
If you don't want to learn but finish quick, here is :
For login, you need JDialog, JLabel, JTextField, JButton,
given location? --> You must know layout. --> if you want to learn go to the link above; learn The best is GridBagLayout.
if you don't want to learn but finish quick, here is :
// x, y, width, height ==> you must put int value
class MyDialog extends JDialog {
this.setLayout(null);
JLabel myLabel = new JLabel("Login");
myLabel.setBounds(x, y, width, height);
myLabel.setBorder(new EtchedBorder()); ---> to see the actual bound of the component.
JLabel myLabel2 = new JLabel("Password");
myLabel2 .setBounds(x, y, width, height);
myLabel2 .setBorder(new EtchedBorder()); ---> to see the actual bound of the component.
JTextField myLoginTextField1 = new JTextField();
myLoginTextField1.setBounds(x, y, width, height);
JTextField myPasswordTextField2 = new JTextField();
myPasswordTextField2 .setBounds(x, y, width, height);
JButton myOKButton = new JButton("OK");
myOKButton.setBounds(x, y, width, height);
JButton myCancelButton = new JButton("Cancel");
myCancelButton.setBounds(x, y, width, height);
{code}____________________________________________________
This will do. Etched border will help you to have proper size. of width and height.
Play around, you will find fun - -
How to set the value in SelectOneChoice
Hi,
I need an help....
can anyone please tell me how to set the value in SelectOneChoice.
I want to set the value at index 3
i am trying selectOneChoice1.setvalue(new Integer(3)); but it is throwing an NullPointerException.
Thanks,
NehaHi,
is it ADF bound? If so then you set the default value to the list binding in the PageDef file. The value of the component must be bound to a method expression, which is why you see an exception. However, I think we need more information
Frank -
How to set filters to a Result view
Hi All,
How to set filters to a result view in web UI.
Thanks & Regards
Nitish.Hi Nitish Kumar,
if you want to sort the table fields like ascending , Descending create one event ex: eh_on_sorting.
in that get the event using thtmlb_event. then check whether sorting is necessary or not.
then get the name of column to be sort by using tableview->column_key.
based on that arrange the field ascending or descending using tableview->column_sort_directin.
ascending or descending.
then sort the collection using collection_wrappor->sort( lv_attrname .. etc).
here is the sample code..
data: lv_bo type ref to if_bol_bo_property_access,
lv_thtmlb_tableview type ref to cl_thtmlb_table_view,
lv_attr_name type name_komp,
lv_sort_order type char1,
lv_stable type abap_bool value abap_false.
try.
lv_thtmlb_tableview ?= iv_htmlb_event_ex.
catch cx_sy_move_cast_error.
exit.
endtry.
if lv_thtmlb_tableview is bound.
* check whether its realy a sorting event
check lv_thtmlb_tableview->event_type = cl_thtmlb_table_view=>co_header_click.
* get name of column to be sorted
lv_attr_name = lv_thtmlb_tableview->column_key.
check lv_attr_name is not initial.
* get sorting direction
case lv_thtmlb_tableview->column_sort_direction.
when 'U'.
lv_sort_order = cl_bsp_wd_collection_wrapper=>sort_ascending.
when 'D'.
lv_sort_order = cl_bsp_wd_collection_wrapper=>sort_descending.
when others.
return.
endcase.
* sort
try.
me->collection_wrapper->sort( iv_attr_name = lv_attr_name
iv_sort_order = lv_sort_order
iv_stable = lv_stable
* IV_SORT_CALLBACK =
catch cx_crm_cic_parameter_error.
* could be a renamed attribute or field which does not belong to the collection
endtry.
* in case of single selection restore the selected row index
if me->selection_mode = selmode_single
or me->selection_mode = selmode_lineedit.
if me->selected_index <> '0'.
me->selected_index = me->collection_wrapper->get_current_index( ).
endif.
endif.
else.
exit.
endif.
Thanks & Regards,
Srinivask -
How to set value for trim and bleed using jsx script?
I have tried using bleedoffsetRect but somehow it is not working. Can anybody please help me on how to set value for trim and bleed using jsx script? Any example will be highly appreciated.
Following is the code I am trying with:
var _saveName = new File ( root_path +_strFileName+".pdf");
var _saveOpts = new PDFSaveOptions();
_saveOpts.printerResolution = 300;
var bleedarray = new Array();
bleedarray[0] =9.00;
bleedarray[1]=9.00;
bleedarray[2]=9.00;
bleedarray[3]=9.00;
_saveOpts.bleedOffsetRect = bleedarray;I would expect although I've not actually tried this for the bleed off set box to be larger than the artbaord and the first two values to be negative or 0…
var bleedarray = new Array(-9,-9,artboard.width+9,artboard.height+9);
Where 'artboard.width' & 'artboard.height' you will have calculated from your file. An Array(9,9,9,9); would not constitute any boxes bounds. -
How to set focus on UI Element
Hi All,
I am using the below code to set the focus on the first row of the table given in the link [How to set focus at UI element ? ] on enter of an event.
data: lr_elem type ref to if_wd_view_element.
lr_elem = view->get_element( <ID of the Link to Action field>).
if lr_elem is bound.
view->request_focus_on_view_elem( lr_elem ).
endif.
I am getting "Cannot use NULL reference as object error at view".
Can you please tell me how to get the reference of the "view".
Thanks
Praveen>
praveenkumar_81 wrote:
> Hi All,
>
> I am using the below code to set the focus on the first row of the table given in the link [How to set focus at UI element ? ] on enter of an event.
>
>
data: lr_elem type ref to if_wd_view_element.
> lr_elem = view->get_element( <ID of the Link to Action field>).
>
> if lr_elem is bound.
> view->request_focus_on_view_elem( lr_elem ).
> endif.
>
> I am getting "Cannot use NULL reference as object error at view".
>
> Can you please tell me how to get the reference of the "view".
>
> Thanks
> Praveen
Hallo Praveen,
have you controlled that id of the Linktoaction ? there you made error.
See it in the ViewElement designer .
should be something like this
lr_elem = view->get_element( 'LTA_name ' ). -
How to set up a master/detail Spry select
Hello, I was trying to build a master/detail select using Spry following the example in the samples folder, but I didn't succed. I think I'm pretty close. I'm using two datasets from two diffrent xml files. The problem is that I don't know how to set a filter probably. Thanks so much.
This is my code:
<script type="text/javascript">
<!--
var dsRubro = new Spry.Data.XMLDataSet("rubro_xml.php", "root/row");
dsRubro.setColumnType("idConsultaRubro", "number");
var dsCategoria = new Spry.Data.XMLDataSet("categoria_xml.php", "root/row");
dsCategoria.setColumnType("idConsultaRubro", "number");
dsCategoria.setColumnType("idConsultaCategoria", "number");
dsCategoria.setColumnType("orden", "number");
//-->
</script>
</head>
<body>
<form>
Rubro:
<span spry:region="dsRubro" id="rubroSelector">
<select spry:repeatchildren="dsRubro" name="rubroSelect" onchange="document.forms[0].categoriaSelect.disabled = true; dsRubro.setCurrentRowNumber(this.selectedIndex);">
<option spry:if="{ds_RowNumber} == {ds_CurrentRowNumber}" value="{idConsultaRubro}" selected="selected">{descripcion}</option>
<option spry:if="{ds_RowNumber} != {ds_CurrentRowNumber}" value="{idConsultaRubro}">{descripcion}</option>
</select>
</span>
Categoria:
<span spry:region="dsCategoria" id="categoriaSelector">
<select spry:repeatchildren="dsCategoria" id="categoriaSelect" name="categoriaSelect">
<option spry:if="{ds_RowNumber} == {ds_CurrentRowNumber}" value="{idConsultaCategoria}" selected="selected">{descripcion}</option>
<option spry:if="{ds_RowNumber} != {ds_CurrentRowNumber}" value="{idConsultaCategoria}">{descripcion}</option>
</select>
</span>Use XPath to filter the data in the second dataset as follows
<!DOCTYPE html>
<html xmlns:spry="http://ns.adobe.com/spry">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script>
var dsRubro = new Spry.Data.XMLDataSet("rubro_xml.php", "root/row");
dsRubro.setColumnType("idConsultaRubro", "number");
var dsCategoria = new Spry.Data.XMLDataSet("categoria_xml.php[idConsultaRubro=-1]", "root/row");
dsCategoria.setColumnType("idConsultaRubro", "number");
dsCategoria.setColumnType("idConsultaCategoria", "number");
dsCategoria.setColumnType("orden", "number");
function newXPath(cat){
dsCategoria.setXPath('root/row[idConsultaRubro='+cat+']');
dsCategoria.loadData();
</script>
</head>
<body>
<form>
Rubro:
<span spry:region="dsRubro" id="rubroSelector">
<select spry:repeatchildren="dsRubro" name="rubroSelect" onchange="newXPath(this.value)">
<option spry:if="{ds_RowNumber} == {ds_CurrentRowNumber}" value="{idConsultaRubro}" selected="selected">{descripcion}</option>
<option spry:if="{ds_RowNumber} != {ds_CurrentRowNumber}" value="{idConsultaRubro}">{descripcion}</option>
</select>
</span>
Categoria:
<span spry:region="dsCategoria" id="categoriaSelector">
<select spry:repeatchildren="dsCategoria" id="categoriaSelect" name="categoriaSelect">
<option spry:if="{ds_RowNumber} == {ds_CurrentRowNumber}" value="{idConsultaCategoria}" selected="selected">{descripcion}</option>
<option spry:if="{ds_RowNumber} != {ds_CurrentRowNumber}" value="{idConsultaCategoria}">{descripcion}</option>
</select>
</span>
</body>
</html>
I hope this helps.
Ben -
How to set the JFrame to be Full screen
yup.. how to set the JFrame to be Full screen mode??
Hi,
You can get the current size of desktop and resize your application to match it.
//Get desktop screen size
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize()
//Set bounds for main window
setBounds(0, 0, screenSize.width, screenSize.height); Br,
J -
Angle increments using shift key. How to set it up?
How to set up the angle increments (stops) to be used with the shift key? I need to set it up to 30 degrees increments.
The Shift key only constrains to 90° and 45° (based on the Constrain Angle in Prefs) and I don’t think you can change that.
At least I have been using Illie for several generations of donkeys and have never hit on (nor needed) a method involving Shift like you are asking for.
I have always found it easier to use the specific tools for Rotating, Scaling etc. rather than using the Selection tool and bounding boxes (as I assume you are doing). Maybe I’m old-fashioned and maybe it’s just a personal quirk, but hitting R or S keys seems to me to be a more convenient way of working. -
How to set height of XControl?
Hello,
I want to set the height of xcontrol,but there is a problem when I try to set it by property node of xcontrol container bounds height. Top and bottom of my control show incomplete.
So,how to set the height of XControl correctly?
Thank you!
Solved!
Go to Solution.Attached you can find a small example how to get it to work. Please note that i limit the smallest value to 40 because lower heights lead to graphical issues when resizing to larger values again.
So you can see that there are limitations to resizing of XControls depending on the facade of the XControl.
hope this helps,
Norbert
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Attachments:
Resize XControl.vi 10 KB -
How movement type is determine in out bound delivery?
Hello,
(1) I want to know, how movement type is determine in out bound delivery (item detail --->Administration tab).
If I want to make a setting of customer return, then where can I assign movement type 451 so that it will appear in OBD?
(iii) Please provide me the path of setting of SD document category ex- J,7 etc (Which appears in T-code OVLP)
Thanks,
MMCHello,
M type (Tcode OMJJ) is determine into the Delv doc on the bases of Sch line Cat(Tcode VOV6) maintain in your sales order's item level .
The relevant Sch line Cat is determined into sales order on the bases (tcode VOV5 of
I Cat + MRP type (if any) .
And the I cat is determined into sales order based on (tcode VOV4)
Sales Doc. Type + Item cat.group (determined from material Master) + Item usage (if any) + ItemCat-HgLvItm (if any).
The std sch line cat for Return is 651.
If you want to have 451 as M type for your material then copy std sch line cat DN and maintain 'Z' Sch Line cat with your M Type.
And determine the same to your I Cat for return in return sale order.
Before executing your process cycle have a look/check on copying control config for Return Order to Delv in Tcode VTLA.
Hope this can assist you.
Thanks & Regards
JP -
How to set first Item in combobox
Hi all,
I am struggling to find out how to set the first item of the
combobox as say "Select" because the fields i display in the
combobox
are optional for the user to select.
I have in the dataprovider of combobox set to an
arraycollection populated by a call to fill method.
But these items should be displayed below "Select".
Can anyone help me on this.
Thanks,
LakshmiHi
Try
yourcomboxox.prompt = "Select";
yourcombobox.selectedIndex = -1;
http://livedocs.adobe.com/flex/201/langref/index.html?mx/controls/ComboBox.html&mx/control s/class-list.html
HTH
John
Maybe you are looking for
-
Hi, I've recently replaced my iphone 5 and I couldn't restore my data into my new phone, as it asked me to do the software upgrade on itunes in my computer. So, I did the itunes upgrade, which is now causing the Runtime error R6034. I wonder if I wou
-
KPIC problem when creating so with Forte C++
Hi, I am trying to create a shared object library using Forte C++. The project contains about 80 files, all of which are compiled separately with the -KPIC option set. Whe I try to create the library (using the -G) option I get an error that says som
-
Stop(); Action doesn't work in AS3?
I'm a designer and usually work in AS2. But I created a movie in as3 (to use the Bones function), and now my stop actions are not working. What I usually do for my movies is break the movie down in parts on the Main timeline (Start/Content/End), plac
-
Simple layout structure for a webshop, need help, details inside
Studied htmldb for abit. Still abit confused as how it all works. Read the user guide/done some of the examples in the 2day course pdf. Here is the thing. For starters I like to have two regions: sidebar with some kind of tree structure where it's po
-
Solution for SuperDrive write problems...
Recently my MacMini developed a problem whereby discs could not be written to...neither CD-ROM nor DVD. The error message would be: "The disc can't be burned, because the device failed to calibrate the laser power level for this media." If your opt