[CLOSED] Adding different Listitems to each ComboBox in Grid

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Adding different Listitems to each ComboBox in Grid

    Hi,

    I have a grid with a component/combobox column.

                    <ColumnModel>
                        <Columns>
                            <ext:Column ID="Column1" runat="server" Text="Tourtyp" DataIndex="FormatedTourType"/>
                            <ext:Column ID="Column3" runat="server" Text="Route" DataIndex="FormatedCategory"/>
                            <ext:Column ID="Column4" runat="server" Text="Fahrzeug" DataIndex="FormatedVehicle"/>
                            <ext:Column ID="Column5" runat="server" Text="Beauftragter" DataIndex="FormatedPlanEmployee"/>
                        <ext:ComponentColumn ID="ComponentColumnNewCategory" 
                            runat="server" 
                            Editor="true"
                            DataIndex="NewRoute"
                            Flex="1"
                            Text="Neue Route">
                            <Component>
                                <ext:ComboBox ID="ComboBoxNewRoute" runat="server">
                                    <Items>
             
                                    </Items>
                                </ext:ComboBox>
                            </Component>
                        </ext:ComponentColumn>
                        </Columns>            
                    </ColumnModel>
    Every Row in the grid needs to have different values in the Combox.

    Row 1: Route1,Route2
    Row 2: No Route
    Row 3: Route3-1,Route3-2

    etc.

    Is there any example how to achieve that? I am filling the Store in Codebehind

    Thanks
    Last edited by Daniil; Mar 21, 2014 at 4:36 PM. Reason: [CLOSED]
  2. #2
    Hi @blueworld,

    You can use a ComponentColumns BeforeBind or/and Bind listeners to populate the ComboBoxes with items.
    Last edited by Daniil; Mar 20, 2014 at 1:09 PM.
  3. #3
    Hi Daniil,

    thank you, but to be honest, I have no idea what to do.

    I have made a simple example.

    Could you please show me what I need to change?

    Row 1 should contain "A" and "B"

    Row 2 should contain "C" and "D"

    Thank you

    
    <%@ Page Language="VB" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html>
    
    <html>
    <head id="Head1" runat="server">
        <title></title>
    
        <script runat="server">
            Private Class TestObject
                Public Property ID As Integer
                Public Property Name As String
            End Class
               
            Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
                If Not ExtNet.IsAjaxRequest Then
                    Dim xx As New Generic.List(Of TestObject)
                    
                    Dim to1 As New TestObject
                    to1.ID = 100
                    to1.Name = "A"
                   
                    xx.Add(to1)
                    
                    Dim to2 As New TestObject
                    to2.Name = "D"
                    
                    xx.Add(to2)
                    
                    FahrzeugeStore.DataSource = xx
                    FahrzeugeStore.DataBind()
                   
                End If
            End Sub
             
             
            
                
        </script>
    
        <style>
       
        </style>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
    
            <ext:Viewport ID="Viewport1" runat="server" Layout="borderLayout">
                <Items>
                    <ext:Panel ID="Panel1" runat="server" Region="Center" Layout="FitLayout">
                        <Items>
                            <ext:GridPanel ID="FahrzeugeGrid" runat="server" Title="Fahrzeugauswahl"
                                Icon="Lorry" Flex="3" ForceFit="true" SelectionMemory="false">
                                <View>
                                    <ext:GridView ID="Gridview1" runat="server" StripeRows="true"></ext:GridView>
                                </View>
                                <Store>
                                    <ext:Store ID="FahrzeugeStore" runat="server">
                                        <Model>
                                            <ext:Model ID="Model1" runat="server" IDProperty="ID">
                                                <Fields>
                                                    <ext:ModelField Name="ID" />
                                                    <ext:ModelField Name="Name" />
                                                </Fields>
                                            </ext:Model>
                                        </Model>
                                        <Listeners>
                                        </Listeners>
                                    </ext:Store>
                                </Store>
                                <ColumnModel>
                                    <Columns>
                                        <ext:Column ID="Column1" runat="server" Text="ID" DataIndex="ID"
                                            Sortable="True" Flex="1" Visible="true" />
                                        <ext:ComponentColumn ID="ComponentColumnNewCategory"
                                            runat="server"
                                            Editor="true"
                                            DataIndex="Name"
                                            Flex="1"
                                            Text="Name">
                                            <Component>
                                                <ext:ComboBox ID="NameCB" runat="server">
                                                    <Items>
                                                    </Items>
                                                </ext:ComboBox>
                                            </Component>
                                        </ext:ComponentColumn>
                                    </Columns>
                                </ColumnModel>
                            </ext:GridPanel>
    
                        </Items>
                    </ext:Panel>
    
    
    
                </Items>
            </ext:Viewport>
        </form>
    </body>
    </html>
  4. #4
    Here is an example.
    <ext:ComponentColumn>
        <Component>
            <ext:ComboBox runat="server" />
        </Component>
        <Listeners>
            <BeforeBind Handler="if (e.rowIndex === 0) { e.config[0].store = ['A', 'B' ]; }
                                 if (e.rowIndex === 1) { e.config[0].store = ['C', 'D' ]; }" />
        </Listeners>
    </ext:ComponentColumn>
    Please also note that there is no sense to use an ID for a ComponentColumn's Component. It is just ignored, because a new component is render=ed for each row, but ids must be unique.
  5. #5
    Hi Daniil,

    thank you for that example, now I have an idea how it does work.

    The only problem is, that I will have 1-n rows, it depends on a database query.
    Is there any way to do that in a more generic way, the best would be in codebehind?
  6. #6
    You could put the data for each row to some JavaScript object (it could be an array) from code behind, then use it in a BeforeBind listener.
  7. #7
    Thank you Daniil,

    it doesnt need to be a combobox, I wonder if there would be a way to do something like this with the new callout feature?
    I just need an option to change the value of each row before submitting the grid, but each row will have different values to choose from.
  8. #8
    Sorry, I don't quite understand the requirement. Please elaborate.
  9. #9
    Ok,

    I have a grid. A specific Column in that grid can have 1-n values.

    Lets say there is a car grid with the car-name and color.
    Before submitting that rows values you should be able to change the color of each car.

    But car A only has "red" and "yellow" as option.
    Car B has "green" and "blue"

    etc.
    Last edited by blueworld; Mar 21, 2014 at 8:35 AM.
  10. #10
    Thank you for the clarification, it sounds clear for me. But how do you want to use a Callout in this scenario?
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] Multicombo with partially readonly listitems
    By mirwais in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 26, 2013, 11:37 AM
  2. [CLOSED] Can't add ListItems to ComboBox in codebehind [1.0]
    By SFritsche in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 18, 2012, 5:05 PM
  3. [CLOSED] ListItems / ComboBox - value is always a String?
    By wagger in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 31, 2011, 3:46 PM
  4. Replies: 3
    Last Post: Mar 10, 2011, 2:05 PM
  5. [CLOSED] adding listitems dynamically in a combobox
    By LeeTheGreek in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Dec 22, 2009, 4:26 PM

Posting Permissions