[CLOSED] GridPanel / Editor / ComboBox : How to show and select the correct Value in a ComboBox in a GridPanel

  1. #1

    [CLOSED] GridPanel / Editor / ComboBox : How to show and select the correct Value in a ComboBox in a GridPanel

    Hey,

    so I have a ComboBox as an Editor in a GridPanel. That ComboBox has its own Store that is populated in code-behind. All ComboBoxes (and thus Stores) has the same values but what value that is Selected should depend on the GridPanels value for that row.

    Here is the GridPanel with the ComboBox as Editor:

    <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
        <Store> 
            <ext:Store ID="Store1" runat="server" >
                <Reader>
                    <ext:ArrayReader>
                        <Fields>
                            <ext:RecordField Name="Id"></ext:RecordField>
                            <ext:RecordField Name="Start" Type="Date"></ext:RecordField>
                            <ext:RecordField Name="End" Type="String" ></ext:RecordField>
                            <ext:RecordField Name="ChoosenId" Type="Int" ></ext:RecordField>
                        </Fields>
                    </ext:ArrayReader>
                </Reader>
            </ext:Store>
        </Store>
        <ColumnModel ID="ColumnModel1" runat="server">
            <Columns>
                <ext:Column Header="Id" DataIndex="Id"/>
                <ext:DateColumn Header="Start" DataIndex="Start" Format="yyyy-MM-dd HH:mm"  />
                <ext:DateColumn Header="End" DataIndex="End" Format="yyyy-MM-dd HH:mm"  />
                <ext:Column Header="ChoosenId" DataIndex="ChoosenId">
                    <Editor>
                        <ext:ComboBox runat="server" ID="ComboBox1"
                            DisplayField="Name" ValueField="cId"
                            TypeAhead = "false" HideTrigger = "false" ForceSelection="false">
                            <Store>
                                <ext:Store runat="server" ID="Store2">
                                    <Reader>
                                        <ext:ArrayReader>
                                            <Fields>
                                                <ext:RecordField Name="cId"></ext:RecordField>
                                                <ext:RecordField Name="Name"></ext:RecordField>
                                            </Fields>
                                        </ext:ArrayReader>
                                    </Reader>
                                </ext:Store>
                            </Store>
                        </ext:ComboBox>
                    </Editor>
                </ext:Column>
            </Columns>
        </ColumnModel>
        <Listeners>
            <AfterEdit Fn="afterEdit" />
        </Listeners>
    </ext:GridPanel>
    and in the code-behind I populate both the GridPanel and the ComboBox separately. Do note that the "ChoosenId" in the Store1 is one of the Id:s in the Store2 (ComboBox). So I want the item in the ComboBox that has the cId == ChoosenId to be selected.

    Code-behind, simplified and stuff:

    List<object> gridPanel1Object = new List<object>();
    foreach (MyGridPanel1Object d in somePlace)
    {
        gridPanel1Object.Add(new object[] 
        {
            d.Id,
            d.Start,
            d.End,
            d.ChoosenId
        });
    }
    Store1.DataSource = gridPanel1Object;
    Store1.DataBind();
    
    // and populate the ComboBox
    List<object> myComboBoxItems = new List<object>();
    foreach (MyComboBoxItem c in someOtherPlace)
    {
        myComboBoxItems.Add(new object[] 
        {
            c.Id,
            c.Name
        });
    }
    Store2.DataSource = myComboBoxItems ;
    Store2.DataBind();
    Right now what I see in the GridPanel is the "ChoosenId" as the number, not as the DisplayField in the ComboBox. Here is a picture that might make it clearer:
    Click image for larger version. 

Name:	delme.png 
Views:	382 
Size:	4.6 KB 
ID:	2679
    Last edited by Daniil; May 05, 2011 at 12:23 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Please use Renderer, see the Department column:
    https://examples1.ext.net/#/GridPane...Field_Mapping/
  3. #3
    Aha, I tried Listenerer/AfterRender first, but that didnt work. Thanks =)

Similar Threads

  1. [CLOSED] gridpanel with combobox column editor
    By Marcelo in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Dec 30, 2011, 6:53 PM
  2. [CLOSED] GridPanel ComboBox Editor with different values per row
    By logicspeak in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 16, 2011, 6:27 AM
  3. [CLOSED] Gridpanel Combobox Editor Issue
    By ndotis in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Nov 17, 2010, 7:06 PM
  4. Replies: 10
    Last Post: Jan 04, 2010, 4:37 PM
  5. ComboBox Editor inside GridPanel
    By jsemple in forum 1.x Help
    Replies: 1
    Last Post: Feb 27, 2009, 11:58 AM

Tags for this Thread

Posting Permissions