PDA

View Full Version : [CLOSED] MultiSelect1 selection works on PageLoad but NOT a Direct Event...



Fahd
Jul 24, 2012, 10:15 PM
MultiSelect doesn't work on a DirectEvent, Any Ideas?



<%@ 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)
{
TabPanel1.SetActiveTab(0);

Store1.DataSource = GetData();
Store1.DataBind();

// MultiSelect1.SelectedItems.Add(new Ext.Net.ListItem { Value = "3" });
}
}

protected void Select(object sender, DirectEventArgs e)
{
MultiSelect1.SelectedItems.Add(new Ext.Net.ListItem { Value = "3" });
}

private static List<Downtime> GetData()
{
var list = new List<Downtime>()
{
new Downtime("1", "Wrap"),
new Downtime("2", "Oven"),
new Downtime("3", "Divider"),
new Downtime("4", "N/A")
};
return list;
}


[Serializable]
public class Downtime
{
public Downtime() { }
public Downtime(string locationId, string description)
{
this.LocationId = locationId;
this.DowntimeDescription = description;
}

public string LocationId { get; set; }
public string DowntimeDescription { get; set; }
}

</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 Examples</title>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<br />
<ext:TabPanel ID="TabPanel1" runat="server" Width="400" Height="500" DeferredRender="false">
<Items>
<ext:FormPanel runat="server" ID="FormPanel1" Title="Title1">
<Items>
<ext:Button OnDirectClick="Select" runat="server" Text="Select Item" />
</Items>
</ext:FormPanel>
</Items>
<Items>
<ext:Panel ID="Panel1" runat="server" Border="false" Width="300" PaddingSpec="2 0 0 0"
Height="248" Title="Title2" Layout="FitLayout">
<Items>
<ext:MultiSelect ID="MultiSelect1" FieldLabel="List" AllowBlank="false" ValueField="LocationId"
runat="server" SingleSelect="true" DisplayField="DowntimeDescription">
<Store>
<ext:Store ID="Store1" runat="server" AutoDataBind="true" AutoLoad="true">
<Reader>
<ext:JsonReader />
</Reader>
<Model>
<ext:Model ID="Model1" runat="server">
<Fields>
<ext:ModelField Name="LocationId" Type="String" />
<ext:ModelField Name="DowntimeDescription" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
</ext:MultiSelect>
</Items>
</ext:Panel>
</Items>
</ext:TabPanel>
</form>
</body>
</html>

Daniil
Jul 25, 2012, 12:52 AM
Hi,

We really appreciate your good examples. Though, please also provide more verbal details.

I mean the following is not so informative.

MultiSelect doesn't work on a DirectEvent

A description like "Populating MultiSelect SelectedItems during DirectEvent doesn't affect to client" would be good.

To fix please call:

MultiSelect1.SelectedItems.Add(new Ext.Net.ListItem { Value = "3" });
MultiSelect1.UpdateSelectedItems();

It's required during DirectEvent.

Fahd
Jul 25, 2012, 4:56 PM
Ok that works, thanks you.

And I'll be aware and be more informative in the future postings...


Hi,

We really appreciate your good examples. Though, please also provide more verbal details.

I mean the following is not so informative.


A description like "Populating MultiSelect SelectedItems during DirectEvent doesn't affect to client" would be good.

To fix please call:

MultiSelect1.SelectedItems.Add(new Ext.Net.ListItem { Value = "3" });
MultiSelect1.UpdateSelectedItems();

It's required during DirectEvent.

Fahd
Jul 25, 2012, 7:28 PM
<%@ 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)
{
TabPanel1.SetActiveTab(0);

Store1.DataSource = GetData();
Store1.DataBind();

MultiSelect1.SelectedItems.Add(new Ext.Net.ListItem { Value = "3" });
}
}

protected void Select(object sender, DirectEventArgs e)
{
MultiSelect1.SelectedItems.Add(new Ext.Net.ListItem { Value = "4" });
MultiSelect1.UpdateSelectedItems();
}

private static List<Downtime> GetData()
{
var list = new List<Downtime>()
{
new Downtime("1", "Wrap"),
new Downtime("2", "Oven"),
new Downtime("3", "Divider"),
new Downtime("4", "N/A")
};
return list;
}


[Serializable]
public class Downtime
{
public Downtime() { }
public Downtime(string locationId, string description)
{
this.LocationId = locationId;
this.DowntimeDescription = description;
}

public string LocationId { get; set; }
public string DowntimeDescription { get; set; }
}

</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 Examples</title>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<br />
<ext:TabPanel ID="TabPanel1" runat="server" Width="400" Height="500" DeferredRender="false">
<Items>
<ext:FormPanel runat="server" ID="FormPanel1" Title="Title1">
<Items>
<ext:Button OnDirectClick="Select" runat="server" Text="Select Item" />
</Items>
</ext:FormPanel>
</Items>
<Items>
<ext:Panel ID="Panel1" runat="server" Border="false" Width="300" PaddingSpec="2 0 0 0"
Height="248" Title="Title2" Layout="FitLayout">
<Items>
<ext:MultiSelect ID="MultiSelect1" FieldLabel="List" AllowBlank="false" ValueField="LocationId"
runat="server" SingleSelect="true" DisplayField="DowntimeDescription">
<Store>
<ext:Store ID="Store1" runat="server" AutoDataBind="true" AutoLoad="true">
<Reader>
<ext:JsonReader />
</Reader>
<Model>
<ext:Model ID="Model1" runat="server">
<Fields>
<ext:ModelField Name="LocationId" Type="String" />
<ext:ModelField Name="DowntimeDescription" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
</ext:MultiSelect>
</Items>
</ext:Panel>
</Items>
</ext:TabPanel>
</form>
</body>
</html>



Ok that works, thanks you.

And I'll be aware and be more informative in the future postings...

Daniil
Jul 25, 2012, 7:54 PM
Confirm, there should be two items selected after clicking the Button. We will investigate, thanks for the report.

If you need to select a single item only, please use:

protected void Select(object sender, DirectEventArgs e)
{
MultiSelect1.SelectedItems.Clear();
MultiSelect1.SelectedItems.Add(new Ext.Net.ListItem { Value = "4" });
MultiSelect1.UpdateSelectedItems();
}

Fahd
Jul 25, 2012, 8:10 PM
I needed to ONLY select one item.

It works like a charm...

Thanks again...


Confirm, there should be two items selected after clicking the Button. We will investigate, thanks for the report.

If you need to select a single item only, please use:

protected void Select(object sender, DirectEventArgs e)
{
MultiSelect1.SelectedItems.Clear();
MultiSelect1.SelectedItems.Add(new Ext.Net.ListItem { Value = "4" });
MultiSelect1.UpdateSelectedItems();
}

Daniil
Aug 17, 2012, 9:48 AM
Confirm, there should be two items selected after clicking the Button. We will investigate, thanks for the report.

It works if remove

SingleSelect="true"
of the MultiSelect.

Just it doesn't allow to select several items.