[CLOSED] [#31] ComboBox item not getting selected when Used inside the panel in Editor Functionality of Grid

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] [#31] ComboBox item not getting selected when Used inside the panel in Editor Functionality of Grid

    I have hard coded lstObject which is set as Data Source of the Grid Store.
    In DestComponentColumn I have used Panel which contain two component that is DestCombo and DestText.

    Code is running sucessfully and getting the desired User Interface as you can see in the attachment.

    ISSUE:- Items of SourceComboBox is getting selected properly but item is not getting selected for the DestCombo which I have highlighted in the attached screen. Click image for larger version. 

Name:	ComponentColumnAsEditor.png 
Views:	221 
Size:	15.7 KB 
ID:	5494

    Its getting selected when I remove panel from the Component column.But my need is to show either text box or combo box based on some condition.For achieving this I have used panel inside component column as Component column doesnt allow more than one component in it.

    
    <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                List<object[]> lstObject = new List<object[]>();
                lstObject.Add(new object[] {1,1});
                lstObject.Add(new object[] {2,2});
                lstObject.Add(new object[] {3,3});
                
                this.GridStore.DataSource = lstObject;
                this.GridStore.DataBind();
            }
    
        }
    </script>
     
        <script type="text/javascript">
         
            var DestinationRenderer= function (column, cmp, record) {
                if (record.get('DestComboField') == '0') {
                    cmp.componentLayout.owner.items.items[0].hide();
                } else {
                    cmp.componentLayout.owner.items.items[1].hide();
                }
            };
    
            var InsertRecord = function (e) { 
               
                var grid = <%= MapFieldGridPanel.ClientID %>; 
                var position = 0;
                position = (grid.store.data.items.length);
                grid.store.insert(position, {}); 
                grid.getView().focusRow(position);
            }
    
            var DeleteRecord = function (column, cmp, record) { 
                //debugger;
                var grid = <%= MapFieldGridPanel.ClientID %>; 
                grid.store.remove(record);
               
            }
    
        </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <meta name="viewport" content="width=device-width" />
        <title>MapFieldValues</title>
      
           
    </head>
    <body>
        <div>
             <ext:ResourceManager runat="server" />
           
            <ext:GridPanel ID="MapFieldGridPanel" 
                runat="server" 
                Title="ComponentColumn Editor" 
                Width="600" 
                Height="400">
                <Store>
                    <ext:Store ID="GridStore" runat="server">
                        <Model>
                            <ext:Model ID="MapModel" runat="server">
                                <Fields>
                                    <ext:ModelField Name="SourceComboField" Type="Int" />
                                    <ext:ModelField Name="DestComboField" Type="Int" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel ID="SourceColumnModel" runat="server">
                    <Columns>
                         <ext:ComponentColumn ID="SourceComponentColumn" 
                            runat="server" 
                            Editor="true"
                            DataIndex="SourceComboField"
                            Flex="1"
                            Text="Source Field Value">
                            <Component>
                                <ext:ComboBox ID="SourceComboBox" runat="server">
                                    <Items>
                                        <ext:ListItem Text="1" Value="1" Mode="Raw" />
                                        <ext:ListItem Text="2" Value="2" Mode="Raw" />
                                        <ext:ListItem Text="3" Value="3" Mode="Raw" />
                                        <ext:ListItem Text="4" Value="4" Mode="Raw" />
                                        <ext:ListItem Text="5" Value="5" Mode="Raw" />
                                    </Items>
                                </ext:ComboBox>
                            </Component>
                        </ext:ComponentColumn>
                         <ext:ComponentColumn ID="DestComponentColumn" 
                            runat="server" 
                            Editor="true"
                            DataIndex="DestComboField"
                            Flex="1"
                            Text="Destination Field Value" Visible="true">
                            <Component>
                              <ext:Panel ID="DestinationPanel" runat="server">
                                  <Items>
                                      <ext:ComboBox ID="DestCombo" runat="server"> 
                                        <Items>
                                            <ext:ListItem Text="1" Value="1" Mode="Raw" />
                                            <ext:ListItem Text="2" Value="2" Mode="Raw" />
                                            <ext:ListItem Text="3" Value="3" Mode="Raw" />
                                        </Items>
    
                                    </ext:ComboBox>
                                       <ext:TextField ID="DestText" runat="server" />
                                  </Items>
                              </ext:Panel>
                                
                            </Component>
                             <Listeners >
                               <Bind Fn="DestinationRenderer"></Bind>
                           </Listeners> 
                        </ext:ComponentColumn>
    
                        <ext:CommandColumn ID="AddCommandColumn" runat="server">
                            <Commands>
                                <ext:GridCommand CommandName="add" Icon="Add">
                                    
                                </ext:GridCommand>
                               
                            </Commands>
                            <Listeners>
                                <Command Fn="InsertRecord"></Command>
                            </Listeners>
                        </ext:CommandColumn>
    
                        <ext:CommandColumn ID="DeleteCommandColumn" runat="server">
                            <Commands>
                                <ext:GridCommand CommandName="delete" Icon="Delete">
                                </ext:GridCommand>
                            </Commands>
                             <Listeners>
                                <Command Fn="DeleteRecord"></Command>
                            </Listeners>
                        </ext:CommandColumn>
                              
                    </Columns>
                </ColumnModel>          
            </ext:GridPanel>  
        </div>
    </body>
    </html>
    Last edited by Daniil; Feb 14, 2013 at 9:37 AM. Reason: [CLOSED] [#31]
  2. #2
    Hi @alscg,

    Editor="true" mode doesn't support a Panel to be a ComponentColumn's Component.

    You could try to set up a value manually.
    var DestinationRenderer= function (column, cmp, record) {
        if (record.get('DestComboField') == '0') {
            cmp.items.get(0).hide();
            cmp.items.get(1).setValue(record.get("DestComboField"));
        } else {
            cmp.items.get(1).hide();
            cmp.items.get(0).setValue(record.get("DestComboField"));
        }
    };
    Also you will need to listen a Change event of the fields to update a record's field, because Editor="true" won't work.
  3. #3
    We have a ticket to improve ComponentColumn functionality.

    Maybe, we will be able to cover your case as well. Unfortunately, no any time frame for this ticket.
  4. #4
    HI,

    I have converted this code into EXT.NET MVC and bind it with the Model. But I am getting the attached error.I am not getting the proper solution.

    Click image for larger version. 

Name:	Error.png 
Views:	131 
Size:	48.0 KB 
ID:	5550

     <%:this.Html.X().Store(Html.X().Store().ID("StoreSrcCombo")
                                            .Model(Html.X().Model().ID("SrcModel")
                                                            .Fields(
                                                                new ModelField("ID", ModelFieldType.String),
                                                                new ModelField("Name", ModelFieldType.String)
                                                                )                                            
                                                  ).DataSource(Model[0])
                                           )
    
                        %>
                        <%:this.Html.X().Store(Html.X().Store().ID("StoreDestCombo")
                                                   .Model(Html.X().Model().ID("DestModel")
                                                                  .Fields(
                                                                        new ModelField("ID", ModelFieldType.String),
                                                                        new ModelField("Name", ModelFieldType.String)
                                                                        )                                            
                                                         ).DataSource(Model[1])
                                                    )
                         %>  
                        
                            <%:this.Html.X().GridPanel()
                                        .ID("MapFieldGridPanel")
                                        .Header(false)
                                        .Border(false)
                                        .Height(400)
                                        .Width(822)
                                        .Cls("x-custom")
                                        .Store(Html.X().Store().ID("GridStore")
                                                       .Model(Html.X().Model().ID("MapModel")
                                                                      .Fields(
                                                                            new ModelField("SourceComboField", ModelFieldType.String),
                                                                            new ModelField("DestComboField", ModelFieldType.String)
                                                                            )                                            
                                                             ).DataSource(Model[2])
                                                        )
                                        .ColumnModel(
                                            Html.X().ComponentColumn()
                                                .ID("SourceComponentColumn")
                                                .Editor(true)
                                                .DataIndex("SourceComboField")
                                                .Width(350)
                                                .Height(47)
                                                .Text("Source Field Value")
                                                .Component(Html.X().ComboBox()
                                                                    .ID("SourceComboBox")
                                                                    .StoreID("StoreSrcCombo")
                                                                    .DisplayField("Name")
                                                                    .ValueField("ID")
                                                                    . Width(310)),
                                            Html.X().ComponentColumn()
                                                .ID("DestComponentColumn")
                                                .Editor(true)
                                                .DataIndex("SourceComboField")
                                                .Width(320)
                                                .Height(47)
                                                .Text("Source Field Value")
                                                .Component(Html.X().Panel()
                                                                    .ID("DestinationPanel")
                                                                    .Border(false)
                                                                    .Items(
                                                                            Html.X().ComboBox()
                                                                            .StoreID("StoreDestCombo")
                                                                            .DisplayField("Name")
                                                                            .ValueField("ID")
                                                                            . Width(348),
                                                                    
                                                                                Html.X().TextField()
                                                                                . Width(348))
                                                                                )
                                                  .Listeners(ls => ls.Bind.Fn = "DestinationRenderer"),
                                            Html.X().CommandColumn()
                                                    .ID("AddCommandColumn")
                                                    .Width(35)
                                                    .Commands(Html.X().GridCommand()
                                                                        .CommandName("add")
                                                                        .Icon(Icon.Add)
                                                                        .OverCls("x-add"))
                                                        .Listeners(ls => ls.Command.Fn = "InsertRecord"),
                                            Html.X().CommandColumn()
                                                    .ID("DeleteCommandColumn")
                                                    .Width(35)
                                                    .Commands(Html.X().GridCommand()
                                                                        .CommandName("delete")
                                                                        .Icon(Icon.Delete)
                                                                        .OverCls("x-add"))
                                                        .Listeners(ls => ls.Command.Fn = "DeleteRecord")              
                                    )
                         %>
  5. #5
    Did you add resource manager?
    Please post full view code
  6. #6
    Quote Originally Posted by Vladimir View Post
    Did you add resource manager?
    Please post full view code
    I was using <ext:ResourceManager ID="ResourceManager1" runat="server" />
    Now I have changed to <%:Html.X().ResourceManager(ViewBag.ManagerConfi g as MvcResourceManagerConfig)%>
    Now its not giving error.
    Thanks.
  7. #7
    Hi @alscg,

    I see the first time such a syntax "<%: %>". Please clarify what is this? What for and how to use?

    Also why don't you use "@"?

    Example .cshtml View
    <!DOCTYPE html>
    
    <html>
    <head>
        <title>Ext.Net.MVC v2 Example</title>    
    </head>
    <body>
        @Html.X().ResourceManager()
    </body>
    </html>
  8. #8
    Quote Originally Posted by Daniil View Post
    Hi @alscg,

    I see the first time such a syntax "<%: %>". Please clarify what is this? What for and how to use?

    Also why don't you use "@"?

    Example .cshtml View
    <!DOCTYPE html>
    
    <html>
    <head>
        <title>Ext.Net.MVC v2 Example</title>    
    </head>
    <body>
        @Html.X().ResourceManager()
    </body>
    </html>
    Please refer http://haacked.com/archive/2011/01/0...reference.aspx

    For the code I took reference of http://mvc.ext.net/#/GridPanel_ComponentColumn/Editor/
    Since we are using ASPX engine for our MVC project,so converted the code from Razor to Web Form Equivalent.

    In .cshtml file you are using @ and for the .aspx we are using <%: %>

    Hope we are taking the correct approach.Please suggest.
  9. #9
    Understand, thank you.

    Please note that in ASPX you can use the common markup.

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
    </body>
    </html>
    Here is an example of using the WebForm view engine in MVC.
    http://mvc.ext.net/#/Items/ASPX_Engine/
  10. #10
    Quote Originally Posted by Daniil View Post
    We have a ticket to improve ComponentColumn functionality.

    Maybe, we will be able to cover your case as well. Unfortunately, no any time frame for this ticket.
    We have committed the improvement to SVN trunk. It will be also available with the v2.2 release.

    Please take a look at the example.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.Store1.Data = new object[]
                {
                    new object[] { 0, 1 },
                    new object[] { 1, "text" },
                    new object[] { 2, DateTime.Now },
                    new object[] { 3, "Item4" },
                    new object[] { 4, true }
                };
            }
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Multiple Editors - Ext.NET Examples</title>
        <link href="/resources/css/examples.css" rel="stylesheet" /> 
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <h1>Multiple Editors</h1>        
    
            <ext:GridPanel 
                runat="server" 
                Title="Multiple Editors" 
                Width="400" 
                Height="180">
                <Store>
                    <ext:Store ID="Store1" runat="server">
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="Index" Type="Int" />
                                    <ext:ModelField Name="Value">
                                        <Convert Handler="if(record.data.Index == 2){return Ext.Date.parse(value, 'Y-m-d\\TH:i:s');} else {return value;}" />
                                    </ext:ModelField>
                                </Fields>
                            </ext:Model>
                        </Model>
                        <Reader>
                            <ext:ArrayReader />
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                         <ext:RowNumbererColumn runat="server" />
    
                         <ext:ComponentColumn runat="server" Flex="1" Editor="true" DataIndex="Value">
                            <Component>
                                <ext:NumberField runat="server" />
                                <ext:TextField runat="server" />
                                <ext:DateField runat="server" />
                                <ext:ComboBox runat="server">
                                    <Items>
                                        <ext:ListItem Text="Item1" />
                                        <ext:ListItem Text="Item2" />
                                        <ext:ListItem Text="Item3" />
                                        <ext:ListItem Text="Item4" />
                                        <ext:ListItem Text="Item5" />
                                    </Items>
                                </ext:ComboBox>
                                <ext:Checkbox runat="server" />
                            </Component>
                            <Listeners>
                                <BeforeBind Handler="e.config = e.config[e.record.data.Index];" />
                            </Listeners>
                            <Renderer Handler="metadata.style='color:gray;'; return '[none]';" />
                         </ext:ComponentColumn>
                    </Columns>
                </ColumnModel>
            </ext:GridPanel>  
            
        </form>
    </body>
    </html>
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 17
    Last Post: Dec 17, 2012, 11:58 AM
  2. Replies: 0
    Last Post: Sep 08, 2011, 9:59 AM
  3. [CLOSED] ComboBox Editor in Grid reverts selected to VALUE , not TEXT
    By rthiney in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Aug 10, 2011, 3:00 PM
  4. [CLOSED] combobox column in grid and get selected item on row click
    By legaldiscovery in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 23, 2011, 2:38 PM
  5. [CLOSED] ComboBox inside a Grid (editor)
    By GmServizi in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Nov 19, 2009, 10:48 AM

Posting Permissions