[CLOSED] [#529] MultiSelect scroll position is not getting maintianed

  1. #1

    [CLOSED] [#529] MultiSelect scroll position is not getting maintianed

    Hi,

    I have a simple Multiselect list used for displaying countries.
    The issue which i am facing is, when user select all the countries and want to deselect last 2 countries or first country the scroll position is not maintained.

    This issue also exists in Multiselect examples on https://examples2.ext.net/
    In order to reproduce this issue please deselect first & last country after selecting all the countries

    Here is my sample code

    Index View

    
    @model List<TestProject.Controllers.MultiSelectController.Country>
    
    @using System.Web.Optimization;
    @{
        ViewBag.Title = "Home Page";
        var X = Html.X();
    }
    
    @(Html.X().ResourceManager(ViewBag.ManagerConfig as MvcResourceManagerConfig))
    
    <script>
        var SelectAllCountries = function () {
            App.RegionList.setSelectedItems(App.RegionList.store.getAllRange())
        }
    
        var DeselectAllCountries = function () {
            App.RegionList.boundList.getSelectionModel().deselectAll();
        }
    </script>
    
    <h2>Multi Select</h2>
    
    @(
         Html.X().Container().ID("cntr").Items(
         
                X.MultiSelect().ID("RegionList").Height(200).Width(300).FieldLabel("Select Coutries").LabelAlign(LabelAlign.Top)
                    .Items(from p in Model select new Ext.Net.ListItem { Text = p.CountryName, Value = p.CountryId.ToString() }),
                                     
                X.Button().Text("Select All").ID("btnSelcetAll").Listeners(ls => ls.Click.Fn = "SelectAllCountries"),
                X.Button().Text("Deselect All").ID("btnDeselectAll").Listeners(ls => ls.Click.Fn = "DeselectAllCountries")
                                     
         )
    )
    Model & Controller:

    public class MultiSelectController : Controller
        {
           
            public class Country
            {
                public int CountryId { get; set; }
                public string CountryName { get; set; }
            }
    
            public ActionResult Index()
            {
                List<Country> list = new List<Country>();
                for (int i = 0; i <= 50; i++)
                {
                    Country obj = new Country();
                    obj.CountryId=i;
                    obj.CountryName="Country-"+i;
                    list.Add(obj);
                }
    
                return View(list);
            }
    
        }
    Thanks
    Last edited by Daniil; Aug 05, 2014 at 1:12 PM. Reason: [CLOSED] [#529]
  2. #2
    Hi @PriceRightHTML5team,

    Thank you for the report.

    I have reproduced. Investigating.
  3. #3
    Please try this fix.
    Ext.ux.form.MultiSelect.override({
        setValue: function (value) {
            var me = this,
                rs,
                selModel = me.boundList.getSelectionModel();
    
            // Store not loaded yet - we cannot set the value
            if (!me.store.getCount()) {
                me.store.on({
                    load: Ext.Function.bind(me.setValue, me, [value]),
                    single: true
                });
                return;
            }
    
            value = me.setupValue(value);
            me.mixins.field.setValue.call(me, value);
    
            if (me.rendered) {
                selModel.preventFocus = true;
                ++me.ignoreSelectChange;
                selModel.deselectAll();
                rs = me.getRecordsForValue(value);
                if (rs.length > 0) {
                    selModel.select(rs);
                }
                --me.ignoreSelectChange;
                selModel.preventFocus = false;
            } else {
                me.selectOnRender = true;
            }
        }
    });
  4. #4
    Thanks Daniil. It worked
  5. #5
    Created an Issue:
    https://github.com/extnet/Ext.NET/issues/529

    It has been fixed in the SVN trunk, revision 5920. It will go to the v2.5.3 release.
  6. #6
    Thanks Daniil... that's great.

Similar Threads

  1. Infinite scroll and scroll bar position
    By oooh in forum 2.x Help
    Replies: 2
    Last Post: Apr 14, 2014, 7:49 PM
  2. Replies: 11
    Last Post: Aug 06, 2013, 5:29 AM
  3. Maintain scroll position in dataview
    By dotnet in forum 1.x Help
    Replies: 0
    Last Post: Jan 28, 2013, 10:10 AM
  4. [CLOSED] Grid - scroll position
    By jwf in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 26, 2011, 11:13 PM
  5. multi select scroll position
    By [WP]joju in forum 1.x Help
    Replies: 1
    Last Post: Apr 13, 2009, 12:13 PM

Posting Permissions