[CLOSED] GridPanel SelectionModel

  1. #1

    [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:
    <%@ 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" &#111;nclick="Button1_Click" Text="Switch to View 2" />
                </asp:View>
                <asp:View ID="View2" runat="server">
                    <ext:Button ID="Button2" runat="server" AutoPostBack="True" &#111;nclick="Button2_Click" Text="Switch to View 1" />
                </asp:View>
            </asp:MultiView>
        </form>
    </body>
    </html>
    Cheers,
    Timothy
  2. #2

    RE: [CLOSED] GridPanel SelectionModel

    Hi Timothy,

    1. The SelectedID and SelectedIndex works only if set Single mode for a selection model otherwise it ignores
    2. Yes, there is a problem with MultiView because the selection doesn't saving to the ViewState. I'll fix it and post reply


  3. #3

    RE: [CLOSED] GridPanel SelectionModel

    Hello vlad,

    1. Oops you caught me, sorry I forgot that property...
    2. You're awesome!

    Cheers,
    Timothy
  4. #4

    RE: [CLOSED] GridPanel SelectionModel



    Hi Timothy and others...

    We renamed to the .SelectedID property to .SelectedRecordID. This change keeps the naming convention of the "id" properties consistent within the SelectionModel and Reader classes.

    Example

    RowSelectionModel sm = this.GridPanel1.SelectionModel.Primary as RowSelectionModel;
    sm.SelectedRecordID = "8";
    The .SelectedRecordID and .SelectedIndex properties are only applicable when using SingleSelect="true" in the <ext:RowSelectionModel>.

    Example

    <ext:GridPanel> 
        ....
        <SelectionModel>
            <ext:RowSelectionModel runat="server" SingleSelect="true" />
        </SelectionModel>
    </ext:GridPanel>
    Geoffrey McGill
    Founder
  5. #5

    RE: [CLOSED] GridPanel SelectionModel

    Great, thanks for the pointer.

    Does this also mean that the post back issue is resolved in my original request?

    Cheers,
    Timothy
  6. #6

    RE: [CLOSED] GridPanel SelectionModel

    Hi Timothy,

    the fix in the SVN


  7. #7

    RE: [CLOSED] GridPanel SelectionModel

    Awesome vlad ;)

Similar Threads

  1. [CLOSED] PartialExtView and GridPanel SelectionModel
    By Timothy in forum 2.x Legacy Premium Help
    Replies: 15
    Last Post: Aug 30, 2012, 5:20 AM
  2. [CLOSED] GridPanel SelectionModel with Loader
    By softmachine2011 in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 17, 2012, 6:45 AM
  3. Replies: 6
    Last Post: Sep 09, 2011, 9:19 AM
  4. [CLOSED] GridPanel: selectionModel
    By RomualdAwessou in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Jul 22, 2010, 2:23 PM
  5. [CLOSED] GridPanel and SelectionModel
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 9
    Last Post: Sep 06, 2009, 2:55 PM

Posting Permissions