[CLOSED] TagField not clearing tagLabels on empty values and array values.

  1. #1

    [CLOSED] TagField not clearing tagLabels on empty values and array values.

    Hi there

    I've had some issues with the TagField on a FormPanel when performing a loadRecord() or an updateRecord(). When a record has an empty array or string value, the TagField does not clear the tagLabels to reflect the empty value.

    Additionally, it does not return an array during an updateRecord() on the FormPanel, although this might be by design.

    The following is the current override I'm using to address the issue.
            
    Ext.override(Ext.net.TagField, {
                getValue: function () {
                    var delimeter = this.getDelimeter();
                    var state = [];
                    Ext.each(this.value, function (obj) {
                        state.push(obj.value);
                    }, this);
                    
                    // Check for an empty delimeter and return an array instead of a joined string.
                    return delimeter === false || delimeter === "" ? state : state.join(delimeter);
                },
                setValue: function (value, opts) {
                    var me = this;
                    // Fix for empty values not being cleared
                    value = this.convertValue(value);
                    if (value && value.length == 0 && this.tagLabel)
                        this.tagLabel.removeAll();
                    me.callParent(arguments);
                    
                }
            });
    Cheers Peter
    Last edited by Daniil; Mar 13, 2014 at 3:30 PM. Reason: [CLOSED]
  2. #2
    Hi Peter,

    Could you, please, provide a test case to reproduce the problem?
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi Peter,

    Could you, please, provide a test case to reproduce the problem?
    As requested. Select a row with data, then select the blank row. The TagField is not cleared.

    EDIT: Confirming I'm on the latest Nuget published version (2.5.0.30685).

    <%@ Page Language="C#" %>
    
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    
    <script runat="server">
    
        private class DemoItem
        {
            public string Name { get; set; }
            public string[] MyValues { get; set; }
        }
    
    
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
                BindData();
        }
    
        protected void BindData()
        {
            List<DemoItem> items = new List<DemoItem>()
            {
                new DemoItem
                {
                    Name = "Some Values",
                    MyValues = new string[] {"A", "B", "C", "D"}
                },
                new DemoItem
                {
                    Name = "This should be empty",
                    MyValues = new string[] {}
                },
                new DemoItem
                {
                    Name = "More Values",
                    MyValues = new string[] {"ABC", "DEF", "GHI"}
                }
            };
            storeDemo.DataSource = items;
            storeDemo.DataBind();
        }
    </script>
    
    <!DOCTYPE html>
        
    <html>
    <head runat="server">
        
    </head>
    <body>
        <ext:ResourceManager runat="server" Theme="Gray" />
    
        <form runat="server">
           <ext:GridPanel runat="server" Title="Data">
               <Store>
                   <ext:Store runat="server" ID="storeDemo">
                       <Model>
                           <ext:Model runat="server">
                               <Fields>
                                   <ext:ModelField Name="Name" />
                                   <ext:ModelField Name="MyValues" Type="Object" />
                               </Fields>
                           </ext:Model>
                       </Model>
                   </ext:Store>
               </Store>
               <ColumnModel>
                   <Columns>
                       <ext:Column runat="server" Text="Name" DataIndex="Name" />
                       <ext:Column runat="server" Text="Values" DataIndex="MyValues" />
                   </Columns>
               </ColumnModel>
               <SelectionModel>
                   <ext:RowSelectionModel runat="server">
                       <Listeners>
                           <Select Handler="#{frmDetail}.loadRecord(record);" />
                       </Listeners>
                   </ext:RowSelectionModel>
               </SelectionModel>
           </ext:GridPanel>
            
            <ext:FormPanel runat="server" Title="Form Panel" ID="frmDetail" Height="200">
                <Items>
                    <ext:TextField runat="server" Name="Name" FieldLabel="Name" />
                    <ext:TagField runat="server" Name="MyValues" FieldLabel="ArrayValues"/>
                </Items>
                <Buttons>
                    <ext:Button runat="server" Text="Update Record">
                        <Listeners>
                            <Click Handler="#{frmDetail}.updateRecord();" />
                        </Listeners>
                    </ext:Button>
                </Buttons>
            </ext:FormPanel>
    	</form>
    
    
    </body>
    </html>
    Last edited by pgodwin; Mar 11, 2014 at 6:27 AM.
  4. #4
    Thank you! We are investigating.
  5. #5
    It has been fixed in the SVN trunk, revision #5715. It will go to the next public release (v2.6).
  6. #6
    Quote Originally Posted by Daniil View Post
    It has been fixed in the SVN trunk, revision #5715. It will go to the next public release (v2.6).
    Thanks Daniil. Does the fix include getValue() returning an array vs string?
  7. #7
    Quote Originally Posted by pgodwin View Post
    Does the fix include getValue() returning an array vs string?
    No, but we are discussing a possibility to apply that change.

    Could you, please, clarify why you need it personally?
  8. #8
    Quote Originally Posted by Daniil View Post
    No, but we are discussing a possibility to apply that change.

    Could you, please, clarify why you need it personally?
    I need it to maintain the original type that was passed to it. As I have passed an array to the control, I expect the getValue() to return an array back.
    Note that this is how the MultiSelect control works currently.
  9. #9
    Yes, a ComboBox and a MultiCombo work in the same way.

    We are thinking about a TagField's setting to return an array or string. We are not sure yet what will be by default.
  10. #10
    A new TagField's option has appeared in the revision #5718 - ValueMode. It is an enum of Array and String. Defaults to Array.

    Thank you for pointing the problem out!

Similar Threads

  1. [CLOSED] when dateField.Text property is empty contains different values
    By tactime10 in forum 1.x Legacy Premium Help
    Replies: 18
    Last Post: Apr 16, 2013, 7:59 AM
  2. Replies: 3
    Last Post: Mar 25, 2011, 9:55 AM
  3. [CLOSED] Clearing EVENTTARGET and EVENTARGUMENT values
    By jchau in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jan 13, 2010, 8:11 AM
  4. [CLOSED] Empty values from text fields
    By CSG in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Apr 21, 2009, 10:14 AM

Tags for this Thread

Posting Permissions