[CLOSED] Problem with Inherited Combo Box

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Problem with Inherited Combo Box

    Good afternoon
    We are evaluating the migration issues for our Application (Build on Ext.Net 2.2, should be migrated to 2.4).
    One of the issues we found belongs to a Combobox Control we created based on the Ext.Net Combo...

    The Created JS shows an empty Store :

    {id:"ContentPlaceHolder2_ucDeclarationGrid_colDecl arationStatus",width:75,headerItems:[{id:"ContentPlaceHolder2_ucDeclarationGrid_cboStat us",xtype:"combobox",matchFieldWidth:false,listCon fig:{height:300,width:320,itemSelector:".x-boundlist-item"},queryMode:"local",valueField:"CodeValue",store:,listeners:{blur:{fn:function(item){if (this.store.find(this.valueField, this.getValue()) < 0) {this.setValue(null, true);}}}}}],align:"right",dataIndex:"DeclarationStatus",sorta ble:true,text:"Status",listeners:{afterrender:{fn: function(item){this.keyNav.disable();}}}}


    Here's a bit of our Code - This Class Inherits from ComboBox

        Private Sub CodeComboBoxBeforeClientInit(sender As Observable) Handles Me.BeforeClientInit
            If Not Page.IsPostBack And Not ExtNet.IsAjaxRequest Then
    
              Dim tempData As List(Of CodeAndDescriptionDTO)
    
              ValueField = "CodeValue"
              tempData = GetData(DateTime.Now, SortOrder.Ascending, _sortType.ToString())
    
              _store = New Store()
              _store.ID = "store_" + ID
              _store.Model.Add(GetModel())
    
              _store.DataSource = tempData
              _store.DataBind()
    
              Store.Add(_store)
    
            End If
    
        End Sub
    
        Private Function GetModel() As Model
          Dim modl As New Model
    
          modl.Fields.Add(New ModelField("CodeId"))
          modl.Fields.Add(New ModelField("Value"))
          modl.Fields.Add(New ModelField("Description"))
          modl.Fields.Add(New ModelField("CodeValue"))
          modl.Fields.Add(New ModelField("text"))
    
          modl.IDProperty = "CodeId"
    
          Return modl
        End Function
    This Code worked with Ext.Net 2.2...

    Any Idea about that problem ?

    Peter
    Last edited by Daniil; Jan 31, 2014 at 5:50 AM. Reason: [CLOSED]
  2. #2
    Hi Peter,

    I cannot reproduce with the example below. Please provide your full test case.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        public class MyComboBox : ComboBox
        {
            protected override void OnBeforeClientInit(Observable sender)
            {
                base.OnBeforeClientInit(sender);
                Store store = new Store()
                {
                    Model =
                    {
                        new Model() 
                        {
                            Fields = 
                            {
                                new ModelField("value"),
                                new ModelField("text"),
                            }
                        }
                    },
                    Reader = 
                    { 
                        new ArrayReader() 
                    },
                    DataSource = new object[] 
                    { 
                        new object[] { "1", "Item 1" },
                        new object[] { "2", "Item 2" },
                        new object[] { "3", "Item 3" }
                    }
                };
    
                this.Store.Add(store);
                
            }
             
        }
    
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.Form.Controls.Add(new MyComboBox());
            }
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
        </form>
    </body>
    </html>
  3. #3
    I made a demo solution which shows the error !

    How can I send you the Solution (Zip-File, 31kB) ?

    Peter
  4. #4
    Unlike, a whole project is required.

    Please provide a sample like I provided. It should be possible.
  5. #5
    Quote Originally Posted by Daniil View Post
    It should be possible.
    I try to merge it into one page ...

    Peter
    Last edited by Peter.Treier; Jan 23, 2014 at 1:11 PM.
  6. #6
    Here we go :-)

    Daniil, I have no Idea how to access the ComboBox, defined in the Script Block, in MarkUp !? So I let it open in the Example...

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="CodeComboBox.WebForm1" %>
    <%@ Import Namespace="Ext.Net" %>
    
    <!DOCTYPE html>
    
    <script runat="server" type="text/VB">
      
      Public Class CodeComboBox
        Inherits ComboBoxBase
      
        Public Enum CodeDomain
          STATUS
        End Enum
    
        Public Enum SortTypes
          Numeric
          Text
        End Enum
    
        Friend _sortType As SortTypes
        Public WriteOnly Property SortType As SortTypes
          Set(value As SortTypes)
            _sortType = value
          End Set
        End Property
    
        Private _domainName As CodeDomain
    
        Public WriteOnly Property DomainName As CodeDomain
          Set(value As CodeDomain)
            _domainName = value
          End Set
        End Property
    
        Private _store As Store
        Private _model As Model
    
        Public Sub New()
          MyBase.New()
          QueryMode = DataLoadMode.Local
          Listeners.Blur.Handler = "if (this.store.find(this.valueField, this.getValue()) < 0) {this.setValue(null, true);}"
    
          'Prevent the user from writing non codes into the ComboBox
          ForceSelection = True
    
          QueryMode = QueryMode
        End Sub
    
        Private Sub CodeComboBoxAfterClientInit(sender As Observable) Handles Me.AfterClientInit
          PrepareDisplayTemplate()
        End Sub
    
        Private Sub CodeComboBoxBeforeClientInit(sender As Observable) Handles Me.BeforeClientInit
    
          If Not Page.IsPostBack And Not ExtNet.IsAjaxRequest Then
    
            Dim tempData As List(Of CodeAndDescriptionDTO) = New DemoData().data
    
            ValueField = "CodeValue"
    
            tempData = PrepareDisplay(tempData)
    
            _store = New Store()
            _store.ID = "store_" + ID
    
            _model = GetModel()
            _store.Model.Add(_model)
    
            _store.DataSource = tempData
            _store.DataBind()
    
            Store.Add(_store)
    
          End If
    
        End Sub
    
        Private Function PrepareDisplay(tempData As IEnumerable(Of CodeAndDescriptionDTO)) As List(Of CodeAndDescriptionDTO)
          Dim ret As New List(Of CodeAndDescriptionDTO)
    
          For Each dto As CodeAndDescriptionDTO In tempData
            Dim newDTO As New CodeAndDescriptionDTO
            newDTO.Id = dto.Id
            newDTO.CodeId = dto.CodeId
            newDTO.Description = dto.Description
            newDTO.CodeValue = dto.CodeValue
    
            Select Case _displayType
    
              Case DisplayTypes.ValueOnly
                newDTO.text = dto.CodeValue
    
              Case DisplayTypes.DescriptionOnly
                newDTO.text = dto.Description
    
              Case DisplayTypes.ValueAndDescription
                newDTO.text = String.Format(_displayFormatString, dto.CodeValue, dto.Description)
    
              Case DisplayTypes.DescriptionAndValue
                newDTO.text = String.Format(_displayFormatString, dto.Description, dto.CodeValue)
    
            End Select
    
            ret.Add(newDTO)
          Next
    
          Return ret
        End Function
    
        Private Sub PrepareDisplayTemplate()
          'the Template to show the Data as two Column ComboBox
          Tpl = New XTemplate()
          Tpl.Html = "<tpl for="".""><tpl if=""[xindex] == 1""><table class=""cbStates-list""><tr><th>Value</th><th>Description</th></tr></tpl><tr class=""x-boundlist-item""><td>{Value}</td><td>{Description}</td></tr><tpl if=""[xcount-xindex]==0""></table></tpl></tpl></Html>"
        End Sub
    
        Private Function GetModel() As Model
          Dim modl As New Model
    
          modl.Fields.Add(New ModelField("CodeId"))
          modl.Fields.Add(New ModelField("Value"))
          modl.Fields.Add(New ModelField("Description"))
          modl.Fields.Add(New ModelField("CodeValue"))
          modl.Fields.Add(New ModelField("text"))
    
          modl.IDProperty = "CodeId"
    
          Return modl
        End Function
      End Class
      
      
      Public Class ComboBoxBase
        Inherits ComboBox
    
        Public Enum DisplayTypes
          ValueOnly
          ValueAndDescription
          DescriptionOnly
          DescriptionAndValue
        End Enum
    
        Friend _displayType As DisplayTypes
    
        Public WriteOnly Property DisplayType As DisplayTypes
          Set(value As DisplayTypes)
            _displayType = value
          End Set
        End Property
    
        Friend _displayFormatString As String = "{0} - {1}"
    
        Public WriteOnly Property DisplayFormatString As String
          Set(value As String)
            _displayFormatString = value
          End Set
        End Property
    
        Friend _pageSize As Int32 = 0
        Friend _sessionStorageProxy As SessionStorageProxy
    
    
        Protected Sub New()
          'Some standart Settings. Remember, the Values are Case Sensitive !
          MatchFieldWidth = False
    
          'Define the look and feel
          ListConfig = New BoundList()
    
          ListConfig.Width = 320
          ListConfig.Height = 300
          ListConfig.ItemSelector = ".x-boundlist-item"
    
        End Sub
    
      End Class
      
      Public Class DemoData
    
        Private Const demoData As String = "[ { ""CodeId"": ""00000000-0000-0000-0000-000000000000"", ""CodeValue"": ""0"", ""Description"": ""eng_200"", ""text"": ""0 - eng_200"" }, { ""CodeId"": ""00000000-0000-0000-0000-000000000000"", ""CodeValue"": ""201"", ""Description"": ""eng_200"", ""text"": ""201 - eng_200"" }, { ""CodeId"": ""00000000-0000-0000-0000-000000000000"", ""CodeValue"": ""202"", ""Description"": ""eng_200"", ""text"": ""202 - eng_200"" }, { ""CodeId"": ""00000000-0000-0000-0000-000000000000"", ""CodeValue"": ""203"", ""Description"": ""eng_200"", ""text"": ""203 - eng_200"" }, { ""CodeId"": ""00000000-0000-0000-0000-000000000000"", ""CodeValue"": ""204"", ""Description"": ""eng_200"", ""text"": ""204 - eng_200"" }, { ""CodeId"": ""00000000-0000-0000-0000-000000000000"", ""CodeValue"": ""207"", ""Description"": ""eng_200"", ""text"": ""207 - eng_200"" }, { ""CodeId"": ""00000000-0000-0000-0000-000000000000"", ""CodeValue"": ""208"", ""Description"": ""eng_200"", ""text"": ""208 - eng_200"" }, { ""CodeId"": ""00000000-0000-0000-0000-000000000000"", ""CodeValue"": ""209"", ""Description"": ""eng_200"", ""text"": ""209 - eng_200"" }, { ""CodeId"": ""00000000-0000-0000-0000-000000000000"", ""CodeValue"": ""210"", ""Description"": ""eng_200"", ""text"": ""210 - eng_200"" } ]"
    
        Public ReadOnly Property data As List(Of CodeAndDescriptionDTO)
          Get
            Dim temp = JSON.Deserialize(Of List(Of CodeAndDescriptionDTO))(demoData)
            Return temp
          End Get
        End Property
    
      End Class
    
      Public Class CodeAndDescriptionDTO
    
        Public Property Id As Guid
    
        Public Property CodeValue As String
        Public Property Description As String
        Public Property CodeId As Guid
        Public Property text As String
        Public Property CodeAndDescription As String
    
    
        Public Sub New()
          CodeValue = String.Empty
          Description = String.Empty
          CodeId = Guid.Empty
          text = String.Empty
          CodeAndDescription = String.Empty
        End Sub
    
    
      End Class
      
      
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
      <body>
        
        <ext:ResourceManager ID="ResourceManager1" runat="server" ScriptMode="Debug" DisableViewState="true" StateProvider="Cookie"/>
    
        <form id="form1" runat="server">
          <div>
            <CodeComboBox ID="cboStatus" runat="server" DomainName="STATUS" SortType="Numeric" DisplayType="ValueAndDescription" />
          </div>
        </form>
      </body>
    </html>
  7. #7
    You can do the same what I did in my example. I modified your sample to get it runnable, but it doesn't reproduce the problem for me.

    Example
    <%@ Page Language="vb" %>
    
    <%@ Import Namespace="Ext.Net" %>
    
    <script runat="server" type="text/VB">
        Public Class CodeComboBox
            Inherits ComboBoxBase
       
            Public Enum CodeDomain
                STATUS
            End Enum
     
            Public Enum SortTypes
                Numeric
                Text
            End Enum
     
            Friend _sortType As SortTypes
            Public WriteOnly Property SortType As SortTypes
                Set(value As SortTypes)
                    _sortType = value
                End Set
            End Property
     
            Private _domainName As CodeDomain
     
            Public WriteOnly Property DomainName As CodeDomain
                Set(value As CodeDomain)
                    _domainName = value
                End Set
            End Property
     
            Private _store As Store
            Private _model As Model
     
            Public Sub New()
                MyBase.New()
                QueryMode = DataLoadMode.Local
                Listeners.Blur.Handler = "if (this.store.find(this.valueField, this.getValue()) < 0) {this.setValue(null, true);}"
     
                'Prevent the user from writing non codes into the ComboBox
                ForceSelection = True
     
                QueryMode = QueryMode
            End Sub
     
            Private Sub CodeComboBoxAfterClientInit(sender As Observable) Handles Me.AfterClientInit
                PrepareDisplayTemplate()
            End Sub
     
            Private Sub CodeComboBoxBeforeClientInit(sender As Observable) Handles Me.BeforeClientInit
     
                If Not Page.IsPostBack And Not ExtNet.IsAjaxRequest Then
     
                    Dim tempData As List(Of CodeAndDescriptionDTO) = New DemoData().data
     
                    ValueField = "CodeValue"
     
                    tempData = PrepareDisplay(tempData)
     
                    _store = New Store()
                    _store.ID = "store_" + ID
     
                    _model = GetModel()
                    _store.Model.Add(_model)
     
                    _store.DataSource = tempData
                    _store.DataBind()
     
                    Store.Add(_store)
     
                End If
     
            End Sub
     
            Private Function PrepareDisplay(tempData As IEnumerable(Of CodeAndDescriptionDTO)) As List(Of CodeAndDescriptionDTO)
                Dim ret As New List(Of CodeAndDescriptionDTO)
     
                For Each dto As CodeAndDescriptionDTO In tempData
                    Dim newDTO As New CodeAndDescriptionDTO
                    newDTO.Id = dto.Id
                    newDTO.CodeId = dto.CodeId
                    newDTO.Description = dto.Description
                    newDTO.CodeValue = dto.CodeValue
     
                    Select Case _displayType
     
                        Case DisplayTypes.ValueOnly
                            newDTO.text = dto.CodeValue
     
                        Case DisplayTypes.DescriptionOnly
                            newDTO.text = dto.Description
     
                        Case DisplayTypes.ValueAndDescription
                            newDTO.text = String.Format(_displayFormatString, dto.CodeValue, dto.Description)
     
                        Case DisplayTypes.DescriptionAndValue
                            newDTO.text = String.Format(_displayFormatString, dto.Description, dto.CodeValue)
     
                    End Select
     
                    ret.Add(newDTO)
                Next
     
                Return ret
            End Function
     
            Private Sub PrepareDisplayTemplate()
                'the Template to show the Data as two Column ComboBox
                Tpl = New XTemplate()
                Tpl.Html = "<tpl for="".""><tpl if=""[xindex] == 1""><table class=""cbStates-list""><tr><th>Value</th><th>Description</th></tr></tpl><tr class=""x-boundlist-item""><td>{Value}</td><td>{Description}</td></tr><tpl if=""[xcount-xindex]==0""></table></tpl></tpl></Html>"
            End Sub
     
            Private Function GetModel() As Model
                Dim modl As New Model
     
                modl.Fields.Add(New ModelField("CodeId"))
                modl.Fields.Add(New ModelField("Value"))
                modl.Fields.Add(New ModelField("Description"))
                modl.Fields.Add(New ModelField("CodeValue"))
                modl.Fields.Add(New ModelField("text"))
     
                modl.IDProperty = "CodeId"
     
                Return modl
            End Function
        End Class
       
       
        Public Class ComboBoxBase
            Inherits ComboBox
     
            Public Enum DisplayTypes
                ValueOnly
                ValueAndDescription
                DescriptionOnly
                DescriptionAndValue
            End Enum
     
            Friend _displayType As DisplayTypes
     
            Public WriteOnly Property DisplayType As DisplayTypes
                Set(value As DisplayTypes)
                    _displayType = value
                End Set
            End Property
     
            Friend _displayFormatString As String = "{0} - {1}"
     
            Public WriteOnly Property DisplayFormatString As String
                Set(value As String)
                    _displayFormatString = value
                End Set
            End Property
     
            Friend _pageSize As Int32 = 0
            Friend _sessionStorageProxy As SessionStorageProxy
     
     
            Protected Sub New()
                'Some standart Settings. Remember, the Values are Case Sensitive !
                MatchFieldWidth = False
     
                'Define the look and feel
                ListConfig = New BoundList()
     
                ListConfig.Width = 320
                ListConfig.Height = 300
                ListConfig.ItemSelector = ".x-boundlist-item"
     
            End Sub
     
        End Class
       
        Public Class DemoData
     
            Private Const demoData As String = "[ { ""CodeId"": ""00000000-0000-0000-0000-000000000000"", ""CodeValue"": ""0"", ""Description"": ""eng_200"", ""text"": ""0 - eng_200"" }, { ""CodeId"": ""00000000-0000-0000-0000-000000000000"", ""CodeValue"": ""201"", ""Description"": ""eng_200"", ""text"": ""201 - eng_200"" }, { ""CodeId"": ""00000000-0000-0000-0000-000000000000"", ""CodeValue"": ""202"", ""Description"": ""eng_200"", ""text"": ""202 - eng_200"" }, { ""CodeId"": ""00000000-0000-0000-0000-000000000000"", ""CodeValue"": ""203"", ""Description"": ""eng_200"", ""text"": ""203 - eng_200"" }, { ""CodeId"": ""00000000-0000-0000-0000-000000000000"", ""CodeValue"": ""204"", ""Description"": ""eng_200"", ""text"": ""204 - eng_200"" }, { ""CodeId"": ""00000000-0000-0000-0000-000000000000"", ""CodeValue"": ""207"", ""Description"": ""eng_200"", ""text"": ""207 - eng_200"" }, { ""CodeId"": ""00000000-0000-0000-0000-000000000000"", ""CodeValue"": ""208"", ""Description"": ""eng_200"", ""text"": ""208 - eng_200"" }, { ""CodeId"": ""00000000-0000-0000-0000-000000000000"", ""CodeValue"": ""209"", ""Description"": ""eng_200"", ""text"": ""209 - eng_200"" }, { ""CodeId"": ""00000000-0000-0000-0000-000000000000"", ""CodeValue"": ""210"", ""Description"": ""eng_200"", ""text"": ""210 - eng_200"" } ]"
     
            Public ReadOnly Property data As List(Of CodeAndDescriptionDTO)
                Get
                    Dim temp = JSON.Deserialize(Of List(Of CodeAndDescriptionDTO))(demoData)
                    Return temp
                End Get
            End Property
     
        End Class
     
        Public Class CodeAndDescriptionDTO
     
            Public Property Id As Guid
     
            Public Property CodeValue As String
            Public Property Description As String
            Public Property CodeId As Guid
            Public Property text As String
            Public Property CodeAndDescription As String
     
            Public Sub New()
                CodeValue = String.Empty
                Description = String.Empty
                CodeId = Guid.Empty
                text = String.Empty
                CodeAndDescription = String.Empty
            End Sub
     
     
        End Class
        
        Sub Page_Load(ByVal Sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim combo As CodeComboBox = New CodeComboBox()
            combo.ID = "cboStatus"
            combo.DomainName = CodeComboBox.CodeDomain.STATUS
            combo.SortType = CodeComboBox.SortTypes.Numeric
            combo.DisplayType = ComboBoxBase.DisplayTypes.ValueAndDescription
            Me.Form.Controls.Add(combo)
        End Sub
    </script>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
    
        <form runat="server">
        </form>
    </body>
    </html>
  8. #8
    Quote Originally Posted by Daniil View Post
    You can do the same what I did in my example. I modified your sample to get it runnable, but it doesn't reproduce the problem for me.
    We use this Ext.Net Version :

    Ext.Net.dll 2.2.0.40838
  9. #9
    Ok, it is the v2.2 public release.

    I cannot reproduce with that release as well.
  10. #10
    Sorry Daniil, my fault !
    We use 2.4.0.30091 (I guess this is the 2.4 public release)

    Peter
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] Problem with inherited treepanel and xmldatabinding
    By infonext in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 26, 2013, 2:11 PM
  2. [CLOSED] Best Way to Extend a ComboBox inherited Control
    By sisa in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 11, 2013, 4:27 PM
  3. [CLOSED] How to add 2 userControl inherited by Ext.Net.Container?
    By ViDom in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Sep 21, 2012, 10:11 AM
  4. [CLOSED] Register javascript resource to inherited control
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 11, 2010, 8:24 PM
  5. Replies: 3
    Last Post: Oct 07, 2009, 6:32 PM

Posting Permissions