[1.0] Change gridpanel selectionModel at runtime

  1. #1

    [1.0] Change gridpanel selectionModel at runtime

    Hi,

    The code below creates javascript error. It a bug about XTemplate rendering. You can avoid this if you remove gridview or remove xtemplate control from grid.Controls before render

    Thanks

    <%@ 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)
            {
                this.Store1.DataSource = this.Data;
                this.Store1.DataBind();
            }
        }
     
        private object[] Data
        {
            get
            {
                return new object[]
                {
                    new object[] { "3m Co", 71.72, 0.02, 0.03, "9/1 12:00am" },
                    new object[] { "Alcoa Inc", 29.01, 0.42, 1.47, "9/1 12:00am" },
                    new object[] { "Altria Group Inc", 83.81, 0.28, 0.34, "9/1 12:00am" }
                };
            }
        }
     
        protected void ChangeClick(object sender, DirectEventArgs e)
        {
            GridPanel1.SelectionModel.Clear();
            GridPanel1.SelectionModel.Add(new CheckboxSelectionModel { CheckOnly=false });
            this.Store1.DataSource = this.Data;
            this.Store1.DataBind();
            GridPanel1.Render();
     
             
        }
    </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></title>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Viewport ID="Viewport1" runat="server" Layout="Fit">
            <Items>
                <ext:GridPanel ID="GridPanel1" runat="server" StripeRows="true" Title="Array Grid"
                    TrackMouseOver="true" Width="600" Height="350" AutoExpandColumn="Company">
                    <Store>
                        <ext:Store ID="Store1" runat="server">
                            <Reader>
                                <ext:ArrayReader>
                                    <Fields>
                                        <ext:RecordField Name="company" />
                                        <ext:RecordField Name="price" Type="Float" />
                                        <ext:RecordField Name="change" Type="Float" />
                                        <ext:RecordField Name="pctChange" Type="Float" />
                                        <ext:RecordField Name="lastChange" Type="Date" DateFormat="M/d hh:mmtt" />
                                    </Fields>
                                </ext:ArrayReader>
                            </Reader>
                        </ext:Store>
                    </Store>
                    <View>
                    <ext:GridView runat="server" ForceFit="true"></ext:GridView>
                    </View>
                    <ColumnModel ID="ColumnModel1" runat="server">
                        <Columns>
                            <ext:Column ColumnID="Company" Header="Company" DataIndex="company" />
                            <ext:Column Header="Price" DataIndex="price">
                                <Renderer Format="UsMoney" />
                            </ext:Column>
                            <ext:Column ColumnID="Change" Header="Change" DataIndex="change" />
                            <ext:Column Header="Change" DataIndex="pctChange" />
                            <ext:DateColumn Header="Last Updated" DataIndex="lastChange" />
                        </Columns>
                    </ColumnModel>
                    <Buttons>
                        <ext:Button ID="Button1" runat="server" Text="Change SelectionModel">
                            <DirectEvents>
                                <Click OnEvent="ChangeClick" />
                            </DirectEvents>
                        </ext:Button>
                    </Buttons>
                </ext:GridPanel>
            </Items>
        </ext:Viewport>
        </form>
    </body>
    </html>
  2. #2
    Hi mdinc,

    Thanks for the excellent code sample.

    I ran your sample against the latest build (available from SVN) and it appears to work correctly. The GridPanel is re-rendered with the new CheckboxSelectionModel.

    It appears the defect you are getting has been fixed and will be publicly available with the next release (soon).

    Hope this helps.
    Geoffrey McGill
    Founder

Similar Threads

  1. [CLOSED] [1.2] Change Image Url at Runtime
    By FVNoel in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Oct 18, 2011, 12:03 PM
  2. Replies: 1
    Last Post: Sep 08, 2010, 9:32 AM
  3. [CLOSED] [1.0] Change gridpanel selectionModel at runtime
    By edigital in forum 1.x Legacy Premium Help
    Replies: 12
    Last Post: Sep 06, 2010, 8:07 PM
  4. [CLOSED] [1.0] Problem adding SelectionModel at runtime
    By edigital in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Aug 04, 2010, 5:30 PM
  5. Localization, Change FieldLabel in runtime
    By Dgsoft.ru in forum 1.x Help
    Replies: 1
    Last Post: Jun 10, 2009, 5:20 PM

Posting Permissions