Combobox in Datagrid

How do I get the combobox that is a renderer in a datagrid's
column to show the value that correlates to the datagrid's
dataprovider data?
Here is the XML for the dataProvider of the datagrid:
<items>
<item>
<productnumber>1</productnumber>
<color>red</color>
<price>12.00</price>
</item>
<item>
<productnumber>2</productnumber>
<color>blue</color>
<price>15.00</price>
</item>
<item>
<productnumber>3</productnumber>
<color>white</color>
<price>10.00</price>
</item>
</items>
Here is the XML of the dataProvider for the combobox:
<colors>
<color>black</color>
<color>green</color>
<color>blue</color>
<color>yellow</color>
<color>white</color>
<color>red</color>
<color>gray</color>
</colors>
So in other words, the datagrid will show a row for each
<item>, and the column that shows <color> is a
combobox, and I want the combobox to be showing the correct
<color> in the list of <colors>. I do know that the
datagrid column for the combobox is an itemRenderer, but how do I
get the combobox to set the right <color> with the
dataProvider=<colors> ?
Can someone please give me an example or point me to one?
Thanks.

"happybrowndog" <[email protected]> wrote in
message
news:gchuu5$e5a$[email protected]..
> How do I get the combobox that is a renderer in a
datagrid's column to
> show the
> value that correlates to the datagrid's dataprovider
data?
http://shigeru-nakagaki.com/index.cfm/2007/8/22/20070822-ComboBox-for-DataGrid-ItemEditor

Similar Messages

  • Problem In Rendreing combobox in DataGrid

    Hi
         i am making a datagrid in which i am rendring a combobox and data provider of my data grid is xml type.The real trick is getting the XML file to be updated when changes to the itemRenderer(combobox) occurred.i am unable to reflect the changes on itemRendrer(combox) from updated xml dynamically.
    can any body guides me how to implement that feature.
    Thanks and regards
       Vineet Osho 

    hi
         i am attaching the code.it will updating the xml.on runtime i just want how to update the combobox when call the service again.for this i need id of combobx.so my problem is that i cant access my rendrer(combobox) from this.
    <root>
    <data>
      <expirationdate>10/13/2010</expirationdate>
      <ldfID>4292</ldfID>
      <effectivedate>10/13/2009</effectivedate>
      <customerpolicyID>1018</customerpolicyID>
      <priorcarriername>m</priorcarriername>
      <lastupdatetimestamp>02/11/2011</lastupdatetimestamp>
      <lossevaluationdate>10/13/2006</lossevaluationdate>
      <lastupdateuserID>13</lastupdateuserID>
      <noopen>no</noopen>
    </data>
    <data>
      <expirationdate>10/13/2009</expirationdate>
      <ldfID>4293</ldfID>
      <effectivedate>10/13/2008</effectivedate>
      <customerpolicyID>1018</customerpolicyID>
      <priorcarriername>m</priorcarriername>
      <lastupdatetimestamp>02/11/2011</lastupdatetimestamp>
      <lossevaluationdate>10/13/2006</lossevaluationdate>
      <lastupdateuserID>13</lastupdateuserID>
      <noopen>yes</noopen>
    </data>
    <data>
      <expirationdate>10/13/2008</expirationdate>
      <ldfID>4294</ldfID>
      <effectivedate>10/13/2007</effectivedate>
      <customerpolicyID>1018</customerpolicyID>
      <priorcarriername>m</priorcarriername>
      <lastupdatetimestamp>02/11/2011</lastupdatetimestamp>
      <lossevaluationdate>10/13/2006</lossevaluationdate>
      <lastupdateuserID>13</lastupdateuserID>
      <noopen>yes</noopen>
    </data>
    <data>
      <expirationdate>10/13/2007</expirationdate>
      <ldfID>4295</ldfID>
      <effectivedate>10/13/2006</effectivedate>
      <customerpolicyID>1018</customerpolicyID>
      <priorcarriername>m</priorcarriername>
      <lastupdatetimestamp>02/11/2011</lastupdatetimestamp>
      <lossevaluationdate>10/13/2006</lossevaluationdate>
      <lastupdateuserID>13</lastupdateuserID>
      <noopen>no</noopen>
    </data>
    <data>
      <expirationdate>10/13/2006</expirationdate>
      <ldfID>4296</ldfID>
      <effectivedate>10/13/2005</effectivedate>
      <customerpolicyID>1018</customerpolicyID>
      <priorcarriername>m</priorcarriername>
      <lastupdatetimestamp>02/11/2011</lastupdatetimestamp>
      <lossevaluationdate>10/13/2006</lossevaluationdate>
      <lastupdateuserID>13</lastupdateuserID>
      <noopen>yes</noopen>
    </data>
    </root>
    <?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"
                   creationComplete="init()" xmlns:local="*">
            <mx:DataGrid id="dgTest" editable="true"  y = "30"
                dataProvider = "{gridData.data}" width = "100%">
                <mx:columns>
                    <mx:DataGridColumn dataField = "lastupdateuserID" width = "80" headerText = "first"
                        sortable="false">
                        <mx:itemRenderer>
                            <fx:Component>
                                <mx:TextInput  width = "100"/>
                            </fx:Component>
                        </mx:itemRenderer>
                    </mx:DataGridColumn>
                    <mx:DataGridColumn  width = "80" headerText = "second" editable="false">
                        <mx:itemRenderer>
                            <fx:Component>
                                <mx:Box>
                                    <fx:Script>
                                        <![CDATA[
                                            import mx.controls.Alert;
                                            public function populateArray(str:String):void{
                                                outerDocument.arrTemp[outerDocument.dgTest.selectedIndex] = str;
                                                outerDocument.xmlGenrate();
                                            public function onCreate():void{
                                                cmbChange.dataProvider = outerDocument.xml.node;
                                        ]]>
                                    </fx:Script>
                                    <mx:ComboBox  id="cmbChange" height="50%" width="50%"
                                        creationComplete="onCreate()"
                                          change="populateArray(cmbChange.selectedItem+'')">
                                    </mx:ComboBox>
                                </mx:Box>
                            </fx:Component>
                        </mx:itemRenderer>
                    </mx:DataGridColumn>
                </mx:columns>
            </mx:DataGrid> 
        <s:Button id="btnSave" label="Save" click="test()"/>
        <fx:Declarations>
            <s:HTTPService id="httpTest" resultFormat="e4x" result="resulthandler(event)" fault=";"/>
        </fx:Declarations>
        <fx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                import mx.events.ChildExistenceChangedEvent;
                import mx.controls.Alert;
                import mx.controls.CheckBox;
                import mx.events.ListEvent;
                import mx.rpc.events.ResultEvent;
                import mx.utils.ObjectUtil;
                import spark.components.ComboBox;
                import spark.components.TextInput;
                import spark.components.supportClasses.ItemRenderer;
                [Bindable]
                public var xml:XML = new XML(<root>
                                        <node>yes</node>
                                        <node>no</node>
                                        </root>);
                [Bindable]
                public var arrTemp:Array =[];
                private var req_XML:XML;
                [Bindable]
                private var gridData:XML;
                private function endHandler(ev:DataEvent):void{
                    Alert.show("Hello");
                public function xmlGenrate():void{
                    var obj:XML = gridData;
                    var temp:XMLList = obj.data.children();
                        var i :int = 0;
                        for(var a:int=0;a < temp.length(); a++){
                            var str1:String = temp[a].localName();
                                var str:XML=createXml(i);
                                if(str1 == 'noopen'){
                                    delete gridData.data.noopen[i];
                                    gridData.data[i].insertChildAfter(gridData.data.lastupdateuserID[i],str);
                                    if(i==gridData.data.length()-1){
                                        return ;
                                    else{
                                        i++;
                                if(obj.data[i].toString().indexOf('noopen')==-1){
                                    gridData.data[i].insertChildAfter(gridData.data.lastupdateuserID[i],str);
                                    if(i==gridData.data.length()-1){
                                        return ;
                                    else{
                                        i++;
                private function createXml(i:int):XML{
                    if(arrTemp[i] == 'null'){
                        req_XML = <noopen></noopen>;
                    else{
                        req_XML = <noopen>{arrTemp[i].toString()}</noopen>;
                    return req_XML;
                private function init():void{
                    httpTest.url = 'data.xml';
                    httpTest.send();
                private function resulthandler(ev:ResultEvent):void{
                    gridData = ev.result as XML;
                    for(var i:int =0;i<gridData.data.length();i++){
                        arrTemp[i] = gridData.data[i].noopen;
                public function test():void{
                    Alert.show(gridData.data+'');
            ]]>
        </fx:Script>
    </s:Application>

  • 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.

  • Combobox in Datagrid with different values

    Hi All,
    I have a datagrid. One of the columns in the datagrid is set
    to display a combobox as the ItemRenderer. Now, the data for the
    combobox is different for each row. How do I set up the data
    provider for the combobox in such a scenario.
    For example : I have a collection of Shirt objects.
    public class Shirt {
    public String id;
    public String type;
    public String[] color; //this is an array
    This should be displayed in the datagrid, with the Color
    column rendered as a combobox. The colors will be different for
    each shirt.
    Thanks
    CS

    Yes. Some more detail:
    in the function,
    override public function set data(value:Object): void {
    the "value" parameter will contain a refernce to an entire
    "Shirt" instance.
    So you can assign the comboBox.dataProvider=value.color;
    Now, It is more complicated than this, because you will want
    the combobox to show the correct value for each row, right?
    For this to happen, you will need a selectedColor property on
    Shirt. When the user chooses a color, you will need to update this
    property with the selection.
    Next, your renderer must read the value of selectedColor and
    set the comboBox.selectedIndex.
    If selectedColor contains the *index* of the color then you
    have it easy. If it contains the color name itself, then you will
    have to for-loop over the color array until yom match the
    selectedColor. then you will have the index and can set
    selectedIndex.
    ComboBox does not support setting the value directly. It is
    pretty easy to extend combo to do this. There are several examples
    out there. I posted a link to one on CFLEX.net
    Tracy

  • ComboBox inside datagrid

    Hi All,
    Let me start with this issue again, maybe someone else can
    help me.
    I have a comboBox inside a datagrid, preview here in this
    group somebody
    show me how to create an event in my datagrid to do my
    calculations
    automatic.
    My problem is that after select an Item in the comboBox I
    have to click
    somewhere else to fire the event.
    Anybody have an idea or sugestion in how to fix this???
    I will include my code below... tks in advance.
    JFB
    public function setDataPrice(event:DataGridEvent):void{
    if(event.dataField == "serviceItemID") {
    // Disable copying data back to the control.
    event.preventDefault();
    var chosenItem:Object =
    ComboBox(event.currentTarget.itemEditorInstance.dataService_cb).selectedItem;
    var chosenId:int = chosenItem.id;
    acData[data_dg.selectedIndex].serviceItemID =
    Number(chosenId);
    acData[data_dg.selectedIndex].price =
    chosenItem.serviceItemPrice;
    acData[data_dg.selectedIndex].rate1000 =
    chosenItem.serviceItemRate;
    acData.refresh();
    // Close the cell editor.
    data_dg.destroyItemEditor();
    // Notify the list control to update its display.
    data_dg.dataProvider.notifyItemUpdate(data_dg.editedItemRenderer);
    if(event.dataField == "qty") {
    if (event.currentTarget.itemEditorInstance.text != ""){
    acData[data_dg.selectedIndex].qty =
    Number(event.currentTarget.itemEditorInstance.text);
    acData.refresh();
    <mx:DataGrid id="price_dg"
    itemEditEnd="calculateRateTotal(event)" x="10"
    y="32" width="590" height="147" editable="true">
    <mx:columns>
    <mx:DataGridColumn headerText="Quantity" dataField="qty"
    labelFunction="formatNumber"/>
    <mx:DataGridColumn headerText="Rate Type" dataField="id"
    rendererIsEditor="true" editorDataField="dummy"
    width="120">
    <mx:itemRenderer>
    <mx:Component>
    <mx:VBox>
    <mx:ComboBox id="rate_cb"
    dataProvider="{outerDocument.acRate}"
    labelField="label" width="120"/>
    </mx:VBox>
    </mx:Component>
    </mx:itemRenderer>
    </mx:DataGridColumn>

    Anybody else can help me with this.
    Tks
    JFB
    "JFB" <[email protected]> wrote in message
    news:[email protected]...
    > Hi All,
    > Let me start with this issue again, maybe someone else
    can help me.
    > I have a comboBox inside a datagrid, preview here in
    this group somebody
    > show me how to create an event in my datagrid to do my
    calculations
    > automatic.
    > My problem is that after select an Item in the comboBox
    I have to click
    > somewhere else to fire the event.
    > Anybody have an idea or sugestion in how to fix this???
    > I will include my code below... tks in advance.
    >
    > JFB
    >
    > public function setDataPrice(event:DataGridEvent):void{
    > if(event.dataField == "serviceItemID") {
    > // Disable copying data back to the control.
    > event.preventDefault();
    >
    > var chosenItem:Object =
    >
    ComboBox(event.currentTarget.itemEditorInstance.dataService_cb).selectedItem;
    > var chosenId:int = chosenItem.id;
    >
    > acData[data_dg.selectedIndex].serviceItemID =
    > Number(chosenId);
    > acData[data_dg.selectedIndex].price =
    > chosenItem.serviceItemPrice;
    > acData[data_dg.selectedIndex].rate1000 =
    > chosenItem.serviceItemRate;
    > acData.refresh();
    > //
    >
    > // Close the cell editor.
    > data_dg.destroyItemEditor();
    >
    > // Notify the list control to update its display.
    >
    >
    data_dg.dataProvider.notifyItemUpdate(data_dg.editedItemRenderer);
    > }
    >
    > if(event.dataField == "qty") {
    > if (event.currentTarget.itemEditorInstance.text != ""){
    > acData[data_dg.selectedIndex].qty =
    > Number(event.currentTarget.itemEditorInstance.text);
    > acData.refresh();
    > }
    > }
    >
    > }
    >
    > <mx:DataGrid id="price_dg"
    itemEditEnd="calculateRateTotal(event)" x="10"
    > y="32" width="590" height="147" editable="true">
    > <mx:columns>
    > <mx:DataGridColumn headerText="Quantity"
    dataField="qty"
    > labelFunction="formatNumber"/>
    > <mx:DataGridColumn headerText="Rate Type"
    dataField="id"
    > rendererIsEditor="true" editorDataField="dummy"
    width="120">
    > <mx:itemRenderer>
    > <mx:Component>
    > <mx:VBox>
    > <mx:ComboBox id="rate_cb"
    dataProvider="{outerDocument.acRate}"
    > labelField="label" width="120"/>
    > </mx:VBox>
    > </mx:Component>
    > </mx:itemRenderer>
    > </mx:DataGridColumn>
    >

  • Combobox and datagrid

    Hi all !
    I have a proplem which i don't solve .
    Can You help me ?and
    Could you rewritten code for me ?
      oItem = oForm.Items.Add("MyGrid", SAPbouiCOM.BoFormItemTypes.it_GRID)
            ' Set the grid dimentions and position
            oItem.Left = 20
            oItem.Top = 60
            oItem.Width = 650
            oItem.Height = 300
            oGrid = oItem.Specific
            oForm.DataSources.DataTables.Add("MyDataTable")
    oForm.DataSources.DataTables.Item(0).ExecuteQuery("select U_NameChild,U_Birthdate,U_*** from OHEM where EmpID='" & EmplID & "'")
            oGrid.DataTable = oForm.DataSources.DataTables.Item("MyDataTable")
            oGrid.Columns.Item(0).Width = 50
            oGrid.Columns.Item(1).Width = 60
            oGrid.Columns.Item(2).Width = 130
            oGrid = oGrid.Columns.Item("U_***")
            oGrid.Type = SAPbouiCOM.BoGridColumnType.gct_ComboBox
            Dim oComboBoxColumn As SAPbouiCOM.ComboBoxColumn
            oComboBoxColumn = New SAPbouiCOM.ComboBoxColumn
            oComboBoxColumn = oGrid.Columns.Item("U_***")
            oComboBoxColumn.ValidValues.Add("1", "Nam")
            oComboBoxColumn.ValidValues.Add("2", "Nu")
    URL=http://imageshack.usIMGhttp://img101.imageshack.us/img101/3803/huynhade1.png[/IMG][/url]

    Dear Nguyen,
    my sample code is as follows, and has been tested, works well.
            oItem = oFirstForm.Items.Add("MyGrid", SAPbouiCOM.BoFormItemTypes.it_GRID)
            ' Set the grid dimentions and position
            oItem.Left = 20
            oItem.Top = 60
            oItem.Width = 650
            oItem.Height = 300
            oGrid = oItem.Specific
            oFirstForm.DataSources.DataTables.Add("MyDataTable")
            oFirstForm.DataSources.DataTables.Item(0).ExecuteQuery("select CardCode, CardType, u_sdn from OCRD")
            oGrid.DataTable = oFirstForm.DataSources.DataTables.Item("MyDataTable")
            oGrid.Columns.Item(0).Width = 50
            oGrid.Columns.Item(1).Width = 60
            oGrid.Columns.Item(2).Width = 60
            oGrid.Columns.Item(2).Type = SAPbouiCOM.BoGridColumnType.gct_ComboBox
            Dim oComboBoxColumn As SAPbouiCOM.ComboBoxColumn
            oComboBoxColumn = oGrid.Columns.Item(2)
            oComboBoxColumn.ValidValues.Add("1", "today")
            oComboBoxColumn.ValidValues.Add("2", "tommorrow")

  • Newbie Flex Question about ComboBox in DataGrid

    Heya!
    Just downloaded Flex today and pleasantly surprised at how
    cool it is. Can any of you fine gents and girls help me out? Why
    doesn't this give me an editable column in my data grid?

    It's a pretty safe assumption that no raw editor except the OEM version will remember the in-camera settings, aside from white balance.
    Why's that? Because those settings don't really do anything anyway - they are just advance instructions for the converter.

  • Datagrid and combobox

    Hi all,
    I have two issues...
    First is that my combobox in datagrid is not populating...
    Here is the code:
    private  function openWindow():void
     var testWindow:TitleWindow = new TitleWindow(); 
    testWindow=TitleWindow(PopUpManager.createPopUp(this, test, true));
    testWindow["Id"]=testDG.selectedItem.ID;
    private   function handle_returnTestAC(e:ResultEvent):void
    testArray=ArrayCollection(e.result);
    <mx:DataGrid  
    toolTip="Click for Description" id="testDG" dataProvider="{testAC}" doubleClickEnabled="true" eventClick="openWindow()">
    <mx:columns>
    <mx:DataGridColumn dataField="ID" headerText="ID" /> 
    <mx:DataGridColumn dataField="Michigan_Produce" headerText="Michigan Produce" />
    <mx:DataGridColumn headerText="Type" dataField="TypeName">  <mx:itemRenderer>  
    <mx:Component>  
    <mx:ComboBox prompt="Type" dataProvider="(testArray)" labelField="TypeName"/>  
    </mx:Component>  
    </mx:itemRenderer>  
    </mx:DataGridColumn>
    </mx:columns> 
    </mx:DataGrid>
    If i call this combobox outside the Datagrid it works:
    <mx:ComboBox  id="cmb" dataProvider="{testAC}" labelField="TypeName" prompt="Type"/>
    2. Problem is that how do I make "Type" DataGridColumn not double click enabled. as when I make a selection in the combobox it does not open the pop up...
    I'll really appreciate any help... thanks...

    1.  Try dataProvider="{outerDocument.tesArray}"
    2.  I didn't understand the question

  • How can recognize the combobox, which is in datagrid.?

    Hi,
        I am developing one sample in WPF, in this sample I placed one combobox in datagrid, now i want to recognize that combobox and select the value from that combobox automatically (in Unit Testing).
    Actually that combobox is visible, while click on "save button", then my data will added to grid and combobox also visible on that time. 
    Regards,
    Bhadram.

    Hi Bhadram,
    Thank you for posting in MSND forum.
    Since this unit test is used to verify whether there have some logic errors in the methods in the C#/ C++ / VB classes and ASP.NET Web Project/ Web Service.
    For more information about this unit test, please refer to it.
    https://msdn.microsoft.com/en-us/library/hh694602.aspx?f=255&MSPPError=-2147217396
    So Unit Test Framework is not suitable for testing UI of WPF applications.
    In addition, I know that since this Coded UI Tests are the recommended approach for testing UI of WPF applications. The coded UI test performs actions on the user interface controls
    for an application and verifies that the correct controls are displayed with the correct values.
    Therefore, I suggest you could try to use the coded UI test to record this
    combobox UI control action and verify the value.
    Best Regards,
    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.

  • Problem with datagrid

    Hi,
    I am doing an application i dont know how to get the data
    from combobox to datagrid. Let us take i have some data like
    arrived and not arrived in my combo box and in datagrid i have one
    column. If i select arrived in my combobox it should be displayed
    in my datagrid. Can any one tell any sample example.Any code.
    Muthu

    Hi,
    You might have to listen to change event of the ComboBox and
    then change the property of the objects in the dataprovider which
    corresponds to the column you want to modify.
    I created a very simple sample. Please find the code
    attached.
    Hope this helps.

  • Dynamic binding of a DataGridTemplateColumn with a ComboBox inside

    Hi all and thank you in advance.
    I wish you could help me 'cause I'm quite a newbye in this world (C# and WPF).
    I need to bind a ComboBox field inside a DataGrid with some data.
    The DataGrid is filled with a collection.
    I need that one or more data from one field (or more) of this collection is bound with data from another DataSet (and collection).
    I need this binding as DYNAMIC and not STATIC:
    if I add a record in the second collection I need this record is avaible in the other collection (DataGrid "collection" before)
    Any suggestion?
    Edit:
    obviously with "if I add" I mean:
    if I add one record in the table I need this record in the ComboBox content of the ComboBox field inside the DataGrid filled with the other collection...

    Ummm... obviously is not a word I would use there mate.
    It's Friday evening and been a tiring week but I'm a bit confused by your explanation.
    I'm guessing you're kind of OK with an observablecollection bound to itemssource of your datagrid.
    If not bind a.... ditto.
    Observablecollection tells you + and - to that collection but not properties.
    You have to implement inotifypropertychanged to do that.
    Then add some notification from your setters on each property.
    kinda like
    using GalaSoft.MvvmLight;
    namespace wpf1
    public class Class1 : ViewModelBase
    private int myVar;
    public int MyProperty
    get
    return myVar;
    set
    myVar = value;
    RaisePropertyChanged();
    Binding comboboxes in datagrids is tricky.
    You have several options.
    You mention datasets and collections.
    I'm going with collection here.
    The thing to realise about the wpf datagrid is datacontext.
    The datacontext of the row is an item in the collection the itemscollection is bound to.
    If you bind a collection of customer then it's in customer it looks for any binding.
    It has to use a bit of weird notation to get to the datacontext of the window.
    That's one route to your data.
    Another is to have an observable collection as a resource.
    http://social.technet.microsoft.com/wiki/contents/articles/26347.wpf-combobox-binding-in-datagrid.aspx
    http://social.technet.microsoft.com/wiki/contents/articles/26200.wpf-dynamicresource-observablecollection.aspx
    Hope that helps.
    Recent Technet articles: Property List Editing;
    Dynamic XAML

  • How to view the records in datagrid using Combo Box Selection

    hi friends,
    i having one combo box,that combo box having 10 students name in list format.
    If i click any one of the students name it will only show the Particular student record in datagrid with respective fields(student name,rollnumber,percentage);
    how i will do this
    please give any suggession or show snippet demo.
    it will be more helpful to do this,
    Thanks in advance
    B.Venktesan.

    Hi,
    As your requirement , i think you will have to use selectedItem or selectedIndex property of combobox. And accordingly fetch data and provide it to dataprovider of datagrid.Following code can help you.
    <?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">
    <fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <fx:Script>
    <![CDATA[
    import mx.collections.ArrayCollection; 
    import mx.controls.Alert; 
    import spark.components.List;[
    Bindable] 
    var array:ArrayCollection = new ArrayCollection(); 
    public function insert():void{ 
    array.addItem(Combo1.selectedItem
    as String);DG1.dataProvider=array;
    ]]>
    </fx:Script>
    <s:ComboBox x="118" y="64" id="Combo1" change="insert()" >
    <s:dataProvider>
    <s:ArrayList>
    <fx:String>AAA</fx:String>
    <fx:String>BBB</fx:String>
    <fx:String>CCC</fx:String>
    </s:ArrayList>
    </s:dataProvider>
    </s:ComboBox>
    <mx:DataGrid x="118" y="154" id="DG1" >
    <mx:columns>
    <mx:DataGridColumn>
    </mx:DataGridColumn>
    </mx:columns>
    </mx:DataGrid></s:Application>
    Thanks and Regards,
    Vibhuti Gosavi | [email protected] | www.infocepts.com

  • Nested XML into comboBox

    Well as stupid as this sounds I can populate a datagrid from
    a dynamic xml source(ASP) using HTTPservice but a basic lack of
    understanding is preventing me from using this data in a comboBox
    Below is my application source that works for populating the
    datagrid in it, but when the data is used in the comboBox as it's
    dataprovider the value is "[object][object]" Ive tried a bunch of
    stuff but I think im conceptualy misunderstanding something about
    retreiving nested values...
    --MY BROKEN EXAMPLE---
    --XML-output-by-asp-document--------
    <product>
    <category>Tile</category>
    <name>Angelic Peach</name>
    </product>
    <product>
    <category>Tile</category>
    <name>Cosmo</name>
    </product>
    <product>
    <category>Tile</category>
    <name>Durva</name>
    </product>
    <product>
    <category>Tile</category>
    <name>Isosilis</name>
    </product>
    <product>
    <category>Tile</category>
    <name>Magaloth</name>
    </product>
    <product>
    <category>Tile</category>
    <name>Trunklin</name>
    </product>
    <product>
    <category>Tile</category>
    <name>Googolfletch</name>
    </product>
    <product>
    <category>Tile</category>
    <name>Moskurbelf</name>
    </product>
    <product>
    <category>Tile</category>
    <name>DoChoaKoa</name>
    </product>
    ---products-component-for-use-in-main-application---
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="
    http://www.adobe.com/2006/mxml"
    width="400" height="300"
    creationComplete="this.productStream.send();">
    <mx:Script>
    <![CDATA[
    import mx.utils.ArrayUtil;
    import mx.utils.XMLUtil
    //var urlPath="
    http://localhost/rogerwilko/AndeanStone/xml.asp";
    function xmlRequest():void {
    // Cancel all previous pending calls.
    productStream.cancel();
    var params:Object = new Object();
    params.func = 'products';
    productStream.send(params);
    ]]>
    </mx:Script>
    <mx:HTTPService id="productStream"
    url="
    http://localhost/rogerwilko/AndeanStone/xml.asp"/>
    <mx:Label text="Select A Product Category" top="0"
    left="0"/>
    <mx:ComboBox id="prodCatList"
    dataProvider="{mx.utils.ArrayUtil.toArray(this.productStream.lastResult.product)}"
    width="200" left="0" top="20" cornerRadius="3" fillAlphas="[0.5,
    0.5]" themeColor="#00ff00" alpha="0.49">
    </mx:ComboBox>
    <mx:DataGrid id="prodList"
    dataProvider="{mx.utils.ArrayUtil.toArray(this.productStream.lastResult.product)}"
    columnWidth="200" width="200" left="0" top="55">
    <mx:columns>
    <mx:DataGridColumn headerText="{prodCatList.value}"
    dataField="name"/>
    </mx:columns>
    </mx:DataGrid>
    </mx:Canvas>
    Thanks in advance for any help you can provide me
    leo

    You will need to specify either a labelField or
    labelFunction. You can use a labelField if the value you want to
    show in the combo box is a first level property of the item.
    If the data you want to display is deeper in the item object,
    and you need to "dot down" to get it use a labelFunction.
    HTTPService resultFormat defaults to Object. I have never
    been comfortable about the way Flex converts xml into objects, so I
    always use e4x. This choice affects the structure of your item
    objects, and therefore the way you need to access the item objects
    properties.
    Try labelField, anif that doesn't work use a labelFunction.
    Note, you can debug the labelFunction quite handily.
    Tracy

  • How to display data in a grid after selecting topic from combo box?

    could someone help me out? i'm displaying a combo box (about
    20 items) vertically. when user selects one of these items, i'd
    like for information regarding that choice to be displayed in my
    data grid. thanks - Karl from Kansas

    If you have the following:
    <mx:ComboBox id="combo_box" dataProvider="{users}"
    labelField="user_name" change="show_details(event)"
    ></mx:ComboBox>
    <mx:DataGrid id="data_grid" >
    <mx:columns>
    <mx:DataGridColumn headerText="Name"
    dataField="user_name"/>
    <mx:DataGridColumn headerText="email"
    dataField="email"/>
    </mx:columns>
    </mx:DataGrid>
    private function show_details(evt:Event):void {
    data_grid.dataProvider = evt.currentTarget.selectedItem
    This assumes that your combo box data has a user_name and
    email property value. Substitute your property values where needed.
    Vygo

  • Coulnd not resolve mx:script "or" mx:operation to a component implementation

    i'm execising flex builder 2's help lessons step by step. i'm
    coding what the guide tell but i've problem when i use
    <mx:script> tag or <mx:operation> tag. i couldn't find
    why it is like that and so i couldn't solve the problem. i'm giving
    you the 2 codes (first one is with mx:Script, second one is with
    mx:operation). please help me about what is wrong.
    here is the codes :
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" creationComplete="createListener();">
    <mx:Script>
    <![CDATA[
    public function createListener():void {
    btnConvert.addEventListener(MouseEvent.CLICK,
    convertCurrency);
    public function convertCurrency(e:Event):void {
    var rate:Number = 120;
    var price:Number = Number(txtPrice.text);
    if (isNaN(price)) {
    lblResults.text = "Please enter a valid price.";
    } else {
    price = price * rate;
    lblResults.text = "Price in Yen: " + String(price);
    ]]>
    </mx:Script>
    <mx:Panel x="20" y="20" width="450" height="150"
    layout="absolute"
    title="Currency Converter">
    <mx:Label x="25" y="37" text="Price in Dollars"/>
    <mx:Label x="120" y="65" id="lblResults"/>
    <mx:TextInput x="120" y="35" id="txtPrice"/>
    <mx:Button x="290" y="35" label="Convert to Yen"
    id="btnConvert"/>
    </mx:Panel>
    </mx:Application>
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute"
    creationComplete="wsBlogAggr.getMostPopularPosts.send()">
    <mx:WebService id="wsBlogAggr" wsdl="
    http://weblogs.macromedia.com/mxna/webservices/mxna2.cfc?wsdl"
    useProxy="false">
    <mx:operation name="getMostPopularPosts">
    <mx:request>
    <daysBack>30</daysBack>
    <limit>{cbxNumPosts.value}</limit>
    </mx:request>
    </mx:operation>
    </mx:WebService>
    <mx:Panel x="10" y="10" width="475" height="400"
    layout="absolute" title="Most Popular Posts">
    <mx:ComboBox x="10" y="10" id="cbxNumPosts"
    change="wsBlogAggr.getMostPopularPosts.send()">
    <mx:Object label="Top 5" data="5"/>
    <mx:Object label="Top 10" data="10"/>
    <mx:Object label="Top 15" data="15"/>
    </mx:ComboBox>
    <mx:DataGrid x="10" y="40" id="dgTopPosts" width="400"
    dataProvider="{wsBlogAggr.getMostPopularPosts.lastResult}">
    <mx:columns>
    <mx:DataGridColumn headerText="Top Posts"
    dataField="postTitle"/>
    <mx:DataGridColumn headerText="Clicks" dataField="clicks"
    width="75" />
    </mx:columns>
    </mx:DataGrid>
    <mx:LinkButton x="10" y="190" label="Select an item and
    click here for full post"/>
    </mx:Panel>
    </mx:Application>

    I tested the first example and it works fine for me. So it is
    not a code problem.
    Tracy

Maybe you are looking for

  • Create folder view with files and tasks

    Good day to you, we want to support our software development procces with Vibe. What we are doing is, we make changes to the source code and protocol corresponding things in certain files. We think in so called "releases" and every release consists o

  • Mac/Windows Compatibility for Word-Help!

    I just recently got Office for my Mac. I created a Word document and emailed it to a business partner. He has Windows and when he opened it, everything (including jpg.'s) were out of place and everything was skewed. He thinks he's running 2003. Any i

  • Password has expired

    right here we go.... i have got past all the problems connecting my xp machine to my macbook. but now when i connect my macbook to the xp machine it asks for the username and password as normal but says that the password has expired. The user i have

  • How do I get music downloaded off itunes back?

    I downloaded some songs off itunes and yesterday my computer's hard drive died - is there any way to get that music back without paying again?

  • S:TileGroup doesn't size to contents

    When the s:TileGroup is wide enough to fit all elements in one row its still 3 rows heigh. Why isn't it dynamically adjusting it's height? Setting requestedRowCount to 1 solves the height problem but blocks content reflowing.