[FIXED] [#524] [#528] Item isn't highlighted in MultiCombo

Page 2 of 2 FirstFirst 12
  1. #11
    .initSelection() appears to accept a single value, does it not?
    It can take multiple items.
    combo.initSelection([{
        value: 1
    }, {
        value: 2
    }]);
  2. #12
    Got it, thanks. As a side note, I've noticed that two clearing calls appear necessary in order to select the items on the server cleanly:

            MultiCombo1.Clear();
            MultiCombo1.SelectedItems.Clear();
    
            MultiCombo1.SelectedItems.Add(new Ext.Net.SelectedListItem { Value = "1" });
            MultiCombo1.SelectedItems.Add(new Ext.Net.SelectedListItem { Value = "2" });
            MultiCombo1.UpdateSelection();
    If I drop either one or both of them, I get problems with highlighting or item appendment instead of addition (the latter makes sense).

    It would be nice if .UpdateSelection() were called seamlessly within the context of the .SelectedItems.Add() execution - maybe, later frameworks take care of that.
    Overall, I'm content with the workarounds and fixes here.
  3. #13
    If I drop either one or both of them, I get problems with highlighting or item appendment instead of addition (the latter makes sense).
    Only this
    MultiCombo1.SelectedItems.Clear();
    should be required, because a SelectedItems collection takes actual selection from POST.

    As for this
    MultiCombo1.Clear();
    I think it should not be required and it appears to be working well for me without that call. If you have time to provide me with a test case and describe exact steps, I could look at.

    It would be nice if .UpdateSelection() were called seamlessly within the context of the .SelectedItems.Add() execution - maybe, later frameworks take care of that.
    Do you mean to call .UpdateSelection() implicitly if a developer changes a SelectedItems collection?
  4. #14
    It seems to me that the culprit of my issue is data-binding of the Store within a direct method. To reproduce, select the last two items in the combo (test3 and test4) and click on the "Select Items" button. Notice that the previous two items are still selected although seemingly not on display. If you un-comment the MultiCombo1.Clear(); call, the issue can't be reproduced.

    <%@ 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)
            {
                Store1.DataSource = new object[]
                {
                    new object[] { 1, "test1" },
                    new object[] { 2, "test2" },
                    new object[] { 3, "test3" },
                    new object[] { 4, "test4" }
                };
                Store1.DataBind();
            }
        }
    
        [DirectMethod]
        public void SelectRecordServer()
        {
            Store1.DataSource = new object[]
                {
                    new object[] { 1, "test1" },
                    new object[] { 2, "test2" },
                    new object[] { 3, "test3" },
                    new object[] { 4, "test4" }
                };
            Store1.DataBind();
            
            //MultiCombo1.Clear();
            MultiCombo1.SelectedItems.Clear();
            MultiCombo1.SelectedItems.Add(new Ext.Net.SelectedListItem { Value = "1" });
            MultiCombo1.SelectedItems.Add(new Ext.Net.SelectedListItem { Value = "2" });
            MultiCombo1.UpdateSelection();
        }
    </script>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Ext.NET Example</title>
        <ext:ResourcePlaceHolder ID="ResourcePlaceHolder1" runat="server" Mode="Script" />
        <ext:ResourcePlaceHolder ID="ResourcePlaceHolder2" runat="server" Mode="Style" />
    
        <script type="text/javascript">
            var selectRecordServer = function () {
                try {
                    X.SelectRecordServer({
                        eventMask: { showMask: true },
                        success: function () {
                        }
                    });
                } catch (e) {
    
                }
            };
        </script>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" DirectMethodNamespace="X" />
            <ext:FormPanel runat="server" Width="400">
                <Items>
                    <ext:MultiCombo ID="MultiCombo1" runat="server" Width="260" DisplayField="Description" ValueField="ID" EnableKeyEvents="true" Delimiter=";" SelectionMode="All" Mode="Local"
                        SelectOnFocus="true" FieldLabel="Items" EmptyText="Select Items...">
                        <Store>
                            <ext:Store ID="Store1" AutoLoad="true" runat="server">
                                <Reader>
                                    <ext:ArrayReader IDProperty="ID">
                                        <Fields>
                                            <ext:RecordField Name="ID" />
                                            <ext:RecordField Name="Description" />
                                        </Fields>
                                    </ext:ArrayReader>
                                </Reader>
                            </ext:Store>
                        </Store>
                    </ext:MultiCombo>
                </Items>
                <BottomBar>
                    <ext:Toolbar runat="server">
                        <Items>
                            <ext:Button runat="server" Text="Select Item (Server)">
                                <Listeners>
                                    <Click Fn="selectRecordServer" />
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </BottomBar>
            </ext:FormPanel>
        </form>
    </body>
    </html>
  5. #15
    It seems to me that the culprit of my issue is data-binding of the Store within a direct method. To reproduce, select the last two items in the combo (test3 and test4) and click on the "Select Items" button. Notice that the previous two items are still selected although seemingly not on display. If you un-comment the MultiCombo1.Clear(); call, the issue can't be reproduced.

    <%@ 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)
            {
                Store1.DataSource = new object[]
                {
                    new object[] { 1, "test1" },
                    new object[] { 2, "test2" },
                    new object[] { 3, "test3" },
                    new object[] { 4, "test4" }
                };
                Store1.DataBind();
            }
        }
    
        [DirectMethod]
        public void SelectRecordServer()
        {
            Store1.DataSource = new object[]
                {
                    new object[] { 1, "test1" },
                    new object[] { 2, "test2" },
                    new object[] { 3, "test3" },
                    new object[] { 4, "test4" }
                };
            Store1.DataBind();
            
            //MultiCombo1.Clear();
            MultiCombo1.SelectedItems.Clear();
            MultiCombo1.SelectedItems.Add(new Ext.Net.SelectedListItem { Value = "1" });
            MultiCombo1.SelectedItems.Add(new Ext.Net.SelectedListItem { Value = "2" });
            MultiCombo1.UpdateSelection();
        }
    </script>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Ext.NET Example</title>
        <ext:ResourcePlaceHolder ID="ResourcePlaceHolder1" runat="server" Mode="Script" />
        <ext:ResourcePlaceHolder ID="ResourcePlaceHolder2" runat="server" Mode="Style" />
    
        <script type="text/javascript">
            var selectRecordServer = function () {
                try {
                    X.SelectRecordServer({
                        eventMask: { showMask: true },
                        success: function () {
                        }
                    });
                } catch (e) {
    
                }
            };
        </script>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" DirectMethodNamespace="X" />
            <ext:FormPanel runat="server" Width="400">
                <Items>
                    <ext:MultiCombo ID="MultiCombo1" runat="server" Width="260" DisplayField="Description" ValueField="ID" EnableKeyEvents="true" Delimiter=";" SelectionMode="All" Mode="Local"
                        SelectOnFocus="true" FieldLabel="Items" EmptyText="Select Items...">
                        <Store>
                            <ext:Store ID="Store1" AutoLoad="true" runat="server">
                                <Reader>
                                    <ext:ArrayReader IDProperty="ID">
                                        <Fields>
                                            <ext:RecordField Name="ID" />
                                            <ext:RecordField Name="Description" />
                                        </Fields>
                                    </ext:ArrayReader>
                                </Reader>
                            </ext:Store>
                        </Store>
                    </ext:MultiCombo>
                </Items>
                <BottomBar>
                    <ext:Toolbar runat="server">
                        <Items>
                            <ext:Button runat="server" Text="Select Items">
                                <Listeners>
                                    <Click Fn="selectRecordServer" />
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </BottomBar>
            </ext:FormPanel>
        </form>
    </body>
    </html>
  6. #16
    Thank you for the test case. It appears that it behaves the same in Ext.NET v2. I will investigate.

    For now, let's say a .Clear() call is required:)
  7. #17
    Created an Issue.
    https://github.com/extnet/Ext.NET/issues/528

    Fixed in SVN.

    v1: revision #5918
    v2: revision #5916

    Now updating of selection clears previous selection first.

    Please note that a .SelectedItems.Clear() call is still required.
  8. #18
    Confirmed, thanks! I'm assuming the call to .UpdateSelection(); is still necessary because it's not working without it.
  9. #19
    Yes, I didn't work on that:) Sorry for misleading you.

    An .UpdateSelection() call is still required. It might be quite complicated to get rid of that.
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 1
    Last Post: Jun 06, 2014, 6:09 AM
  2. Replies: 0
    Last Post: Jun 01, 2013, 10:41 AM
  3. [CLOSED] storeItem (the currently highlighted item) for charttips
    By CarpFisher in forum 2.x Legacy Premium Help
    Replies: 7
    Last Post: Nov 29, 2012, 7:16 AM
  4. Replies: 4
    Last Post: Dec 27, 2011, 3:25 PM
  5. Replies: 0
    Last Post: Sep 19, 2011, 11:11 AM

Posting Permissions