PDA

View Full Version : [CLOSED] MultiSelect change sequence without use drag drop



gs_user
Jul 04, 2012, 7:34 AM
Hi,
I add MuiltiSelect and I want to change the listitem sequence.
I find the sample to change sequence use drag drop,
but I want to use button click to chang . How to resolve it??
4432

Daniil
Jul 04, 2012, 12:39 PM
Hi,

You should deal directly with the MultiSelect Store.

Here is the example how to move the second record at the top.

Example

var store = App.MultiSelect1.getStore(),
record = store.getAt(1);

store.remove(record);
store.insert(0, record);

gs_user
Jul 05, 2012, 2:08 AM
Hi,
I use MultiSelect Store.
At run time, click up or down button,program show up error message.
"例外詳細資訊: System.Web.HttpException: 由於內容不是常值,所以無法取得 form1 的內部內容。"
how to resolve it??



<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Web" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
protected void sequp(object sender, DirectEventArgs e)
{
Ext.Net.Store itemstore = MultiSelect1.GetStore();
Int32 seq = MultiSelect1.SelectedItem.Index;
Ext.Net.ModelProxy record = itemstore.GetAt(MultiSelect1.SelectedItem.Index);
itemstore.Remove(record);
itemstore.Insert(seq - 1, record);
}

protected void seqdown(object sender, DirectEventArgs e)
{
Ext.Net.Store itemstore = MultiSelect1.GetStore();
Int32 seq = MultiSelect1.SelectedItem.Index;
Ext.Net.ModelProxy record = itemstore.GetAt(MultiSelect1.SelectedItem.Index);
itemstore.Remove(record);
itemstore.Insert(seq + 1, record);
}


</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<ext:ResourceManager ID="ResourceManager1" runat="server">
</ext:ResourceManager>

<ext:MultiSelect ID="MultiSelect1" runat="server" Width="100">
<Items>
<ext:ListItem Text="item1"></ext:ListItem>
<ext:ListItem Text="item2"></ext:ListItem>
<ext:ListItem Text="item3"></ext:ListItem>
<ext:ListItem Text="item4"></ext:ListItem>
<ext:ListItem Text="item5"></ext:ListItem>
</Items>

</ext:MultiSelect>
<ext:Button ID="Button1" runat="server" Text="up">
<DirectEvents>
<Click onEvent="sequp">
</Click>
</DirectEvents>
</ext:Button>

<ext:Button ID="Button2" runat="server" Text="down">
<DirectEvents>
<Click onEvent="seqdown">
</Click>
</DirectEvents>
</ext:Button>
</div>
</form>
</body>
</html>




Hi,

You should deal directly with the MultiSelect Store.

Here is the example how to move the second record at the top.

Example

var store = App.MultiSelect1.getStore(),
record = store.getAt(1);

store.remove(record);
store.insert(0, record);

Daniil
Jul 05, 2012, 5:25 AM
I have demonstrated the JavaScript code. I would suggest to implement it client side.