Jun 22, 2016, 11:31 AM
[CLOSED] setSelectedItems on ext:MultiSelect does not work
Hi Guys
Trying to do select all in multiselect control , this worked in ext 2.5 but not working on ext 4.1 , on debugging further in console figured out Ext.Array.from does not assign index property to the array list, so none of select conditions to select item are true , Following is the code please check
code below
Trying to do select all in multiselect control , this worked in ext 2.5 but not working on ext 4.1 , on debugging further in console figured out Ext.Array.from does not assign index property to the array list, so none of select conditions to select item are true , Following is the code please check
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MultiselectList.aspx.cs" Inherits="MultiselectList" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script>
function selectAllItemsinSectionList() {
app.sectionSelector.setSelectedItems(app.sectionSelectorStore.data.items);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<ext:ResourceManager ID="ResourceManager1" runat="server" CleanResourceUrl="true" DirectMethodNamespace="DM_MSelect" Namespace="app">
</ext:ResourceManager>
<ext:Panel ID="pnl1" runat="server" Width="400" Height="500">
<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:Button ID="btmSelectAll" Text="SelectAll Items" runat="server">
<Listeners>
<Click Fn="selectAllItemsinSectionList"></Click>
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<Items>
<ext:MultiSelect SingleSelect="false" ID="sectionSelector" DisplayField="sectionname" ValueField="sectioncode" runat="server" Border="false" AutoScroll="false">
<Store>
<ext:Store runat="server" ID="sectionSelectorStore">
<Model>
<ext:Model ID="Model5" runat="server" IDProperty="orderno">
<Fields>
<ext:ModelField Name="sectioncode"></ext:ModelField>
<ext:ModelField Name="sectionname"></ext:ModelField>
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
</ext:MultiSelect>
</Items>
</ext:Panel>
</div>
</form>
</body>
</html>
code below
using Ext.Net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class MultiselectList : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
this.sectionSelectorStore.Data = Data;
this.sectionSelectorStore.DataBind();
}
}
private List<sections> Data
{
get
{
List<sections> lstData = new List<sections>();
lstData.Add(new sections { sectioncode = "01", sectionname = "Section 1" });
lstData.Add(new sections { sectioncode = "02", sectionname = "Section 2" });
lstData.Add(new sections { sectioncode = "03", sectionname = "Section 3" });
lstData.Add(new sections { sectioncode = "04", sectionname = "Section 4" });
return lstData;
}
}
public class sections
{
public string sectioncode { get; set; }
public string sectionname { get; set; }
}
}