Sep 25, 2008, 9:40 AM
[CLOSED] GridPanel SelectionModel
Hello,
Perhaps you can help me out with the following 2 problems I'm encountering:
1. The CheckboxSelectionModel.SelectedID / SelectedIndex does not appear to be working i nthe example below.
2. When I select a record using the CheckboxSelectionModel and switch my view by hitting "Switch to View 2" and switch back by clicking "Switch to View 1" my selection is lost in the postback.
Example.aspx:
Timothy
Perhaps you can help me out with the following 2 problems I'm encountering:
1. The CheckboxSelectionModel.SelectedID / SelectedIndex does not appear to be working i nthe example below.
2. When I select a record using the CheckboxSelectionModel and switch my view by hitting "Switch to View 2" and switch back by clicking "Switch to View 1" my selection is lost in the postback.
Example.aspx:
<%@ Page Language="C#" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" 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 Page_Load(object sender, EventArgs e)
{
Permissions.DataSource = new object[] {
new object[] { 1, "Permission", "Permission 1" },
new object[] { 2, "Permission", "Permission 2" },
new object[] { 3, "Permission", "Permission 3" },
new object[] { 4, "Permission", "Permission 4" },
new object[] { 5, "Permission", "Permission 5" },
new object[] { 6, "Permission", "Permission 6" }
};
Permissions.DataBind();
if (!IsPostBack)
{
PermissionSelection.SelectedID = "1";
}
}
protected void Button1_Click(object sender, EventArgs e)
{
MultiView.SetActiveView(View2);
}
protected void Button2_Click(object sender, EventArgs e)
{
MultiView.SetActiveView(View1);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Example</title>
</head>
<body>
<p><a href="Example.aspx">Reload</a></p>
<form id="form1" runat="server">
<ext:ScriptManager ID="ScriptManager1" runat="server" />
<ext:Store ID="Permissions"
runat="server"
AutoLoad="True"
GroupField="GroupingName">
<Reader>
<ext:ArrayReader ReaderID="PermissionId">
<Fields>
<ext:RecordField Name="PermissionId" />
<ext:RecordField Name="GroupingName" />
<ext:RecordField Name="DisplayName" />
</Fields>
</ext:ArrayReader>
</Reader>
<SortInfo Field="DisplayName" />
</ext:Store>
<asp:MultiView ID="MultiView" runat="server" ActiveViewIndex="0">
<asp:View ID="View1" runat="server">
<ext:GridPanel ID="GridPanel"
runat="server"
StoreID="Permissions"
AutoExpandColumn="DisplayName"
AutoHeight="True"
StripeRows="True"
Width="300">
<ColumnModel>
<Columns>
<ext:Column ColumnID="GroupingName" DataIndex="GroupingName" Header="Group" />
<ext:Column ColumnID="DisplayName" DataIndex="DisplayName" Header="Permission" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:CheckboxSelectionModel ID="PermissionSelection" runat="server" />
</SelectionModel>
</ext:GridPanel>
<ext:Button ID="Button1" runat="server" AutoPostBack="True" onclick="Button1_Click" Text="Switch to View 2" />
</asp:View>
<asp:View ID="View2" runat="server">
<ext:Button ID="Button2" runat="server" AutoPostBack="True" onclick="Button2_Click" Text="Switch to View 1" />
</asp:View>
</asp:MultiView>
</form>
</body>
</html>
Cheers,Timothy