PDA

View Full Version : [CLOSED] [#529] MultiSelect scroll position is not getting maintianed



PriceRightHTML5team
Jul 24, 2014, 5:28 AM
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 http://examples2.ext.net/ (http://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.Coun try>

@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.sto re.getAllRange())
}

var DeselectAllCountries = function () {
App.RegionList.boundList.getSelectionModel().desel ectAll();
}
</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

Daniil
Jul 24, 2014, 1:34 PM
Hi @PriceRightHTML5team,

Thank you for the report.

I have reproduced. Investigating.

Daniil
Jul 30, 2014, 10:17 AM
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;
}
}
});

PriceRightHTML5team
Jul 30, 2014, 10:41 AM
Thanks Daniil. It worked

Daniil
Aug 05, 2014, 1:11 PM
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.

PriceRightHTML5team
Aug 06, 2014, 4:36 AM
Thanks Daniil... that's great.