How to deselect checked rows after reload the grid panel with checkboxselectionmodel in version2.1

Page 1 of 4 123 ... LastLast
  1. #1

    How to deselect checked rows after reload the grid panel with checkboxselectionmodel in version2.1

    A gridpanel is used in a web user control "window1", the selection model is CheckboxSelectionModel as follow:
     <SelectionModel>
                    <ext:CheckboxSelectionModel runat="server" RowSpan="1" Mode="Multi" />
                </SelectionModel>
    I checked some rows and closed the widow1, then open the window and reload the datasouse of the girdpanel again. The selected rows is still selected as follows:
    Click image for larger version. 

Name:	idpage.png 
Views:	62 
Size:	10.1 KB 
ID:	8561
    But I want all the rows deselected.
    I used these code to deselect or clear the selected rows:
     protected void StorePart_Refresh(object sender, StoreReadDataEventArgs e)
            {
                         ......
                    //RowSelectionModel sm = this.GridPanelPart.SelectionModel.Primary as RowSelectionModel;
                    //sm.SelectedRows.Clear();
                    //sm.UpdateSelection();
    
                    CheckboxSelectionModel cbm = this.GridPanelPart.SelectionModel.Primary as CheckboxSelectionModel;
                    cbm.SelectedRows.Clear();
    
                    cbm.UpdateSelection();
    
                    //cbm.ClearSelection();
                    //cbm.DeselectAll();
             }
    But all these methods didn't work . What message did I Missed ?
  2. #2
    Hi @hongxue,

    I have some ideas why it might be, but I need a runnable sample to investigate in details.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @hongxue,

    I have some ideas why it might be, but I need a runnable sample to investigate in details.
    I do not know how to supply a runalble example. here is the relative codes. I used the Linq to SQL to query the SQL database. Can these codes prove some help? If not ,would you please tell me your ideas, and let me have a test.
    <ext:GridPanel ID="GridPanelPart" runat="server" Region="Center" Icon="ApplicationViewColumns">
                <Store>
                    <ext:Store ID="StorePart" runat="server" RemoteSort="false" OnReadData="StorePart_Refresh"
                        WarningOnDirty="false">
                        <Proxy>
                            <ext:PageProxy />
                        </Proxy>
                        <Model>
                            <ext:Model runat="server" IDProperty="Tool_PartId">
                                <Fields>
                                    <ext:ModelField Name="Tool_PartId" />
                                    <ext:ModelField Name="Tool_PartCode" />
                                    <ext:ModelField Name="Tool_PartName" />
                                    <ext:ModelField Name="StyleName" />
                                    <ext:ModelField Name="LeftInterface" />
                                    <ext:ModelField Name="RightInterface" />
                                    <ext:ModelField Name="Tool_PartLength" />
                                    <ext:ModelField Name="Tool_PartMaterial" />
                                    <ext:ModelField Name="BrandName" />
                                    <ext:ModelField Name="Tool_PartPrice" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:RowNumbererColumn ID="RowNumbererColumn1" runat="server" />
                        <ext:Column ID="Column1" runat="server" DataIndex="Tool_PartId" Text="刀具类码" Width="180" />
                        <ext:Column ID="Column2" runat="server" DataIndex="Tool_PartCode" Text="出厂编号" Width="180" />
                        <ext:Column ID="Column3" runat="server" DataIndex="Tool_PartName" Text="刀具名称" Width="240" />
                        <ext:Column ID="Column4" runat="server" DataIndex="StyleName" Text="刀具类型" />
                        <ext:Column ID="Column5" runat="server" DataIndex="LeftInterface" Text="左端接口" />
                        <ext:Column ID="Column6" runat="server" DataIndex="RightInterface" Text="右端接口" />
                        <ext:Column ID="Column7" runat="server" DataIndex="Tool_PartLength" Text="有效参数" />
                        <ext:Column ID="Column8" runat="server" DataIndex="Tool_PartMaterial" Text="刀具材料" />
                        <ext:Column ID="Column9" runat="server" DataIndex="BrandName" Text="品牌" />
                        <ext:Column ID="Column10" runat="server" DataIndex="Tool_PartPrice" Text="单价" />
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:CheckboxSelectionModel runat="server" RowSpan="1" Mode="Multi" />
                </SelectionModel>
                <BottomBar>
                    <ext:PagingToolbar runat="server" />
                </BottomBar>
            </ext:GridPanel>
            protected void StorePart_Refresh(object sender, StoreReadDataEventArgs e)
            {
                int start = e.Start;
                if (start < 0)
                    start = 0;
                int limit = e.Limit;
                if (limit < 0)
                    limit = StorePart.PageSize;
    
                if (service != null)
                {
                    List<string> leftfaces = new List<string>(HiddenLeftFace.Text.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries));
                    List<string> rightfaces = new List<string>(HiddenRightFace.Text.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries));
                    List<string> partids = new List<string>(HiddenPart.Text.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries));
    
                    Hashtable hswhere = new Hashtable();
                    hswhere.Add("*", TextFieldFind.Text);
                    hswhere.Add("styleId", HiddenStyleID.Value);
                    hswhere.Add("InerfaceIdL", HiddenInterfaceL.Value);
                    hswhere.Add("InerfaceIdR", HiddenInterfaceR.Value);
                    //hswhere.Add("SpecificationID", hideToolId1.Value);
    
                    int allrecord = 0;
    
                    int pageindex = 1;
                    if (e.Start > 0)
                        pageindex = (start / limit) + 1;
                    this.StorePart.DataSource = service.QuerySingleTool(rightfaces, leftfaces, partids, hswhere, start, limit, ref allrecord);
                    (this.StorePart.Proxy[0] as PageProxy).Total = allrecord;
                    this.StorePart.DataBind();
    
                    //RowSelectionModel sm = this.GridPanelPart.SelectionModel.Primary as RowSelectionModel;
                    //sm.SelectedRows.Clear();
                    //sm.UpdateSelection();
    
                    CheckboxSelectionModel cbm = this.GridPanelPart.SelectionModel.Primary as CheckboxSelectionModel;
                    cbm.SelectedRows.Clear();
    
                    cbm.UpdateSelection();
    
                    //cbm.ClearSelection();
                    //cbm.DeselectAll();
    
                }
  4. #4
    You can use some dummy data instead of a database. We should be able to copy, paste and run your sample without any changes.

    For example, as you can do with this sample.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <%@ Import Namespace="System.Collections.Generic" %>
    
    <script runat="server">
        public List<object> MyData = new List<object> 
        { 
            new { test = "test1" },
            new { test = "test2" },
            new { test = "test3" },
            new { test = "test4" },
            new { test = "test5" },
            new { test = "test6" },
            new { test = "test7" },
            new { test = "test8" },
            new { test = "test9" }
        };
    
        protected void Store_ReadData(object sender, StoreReadDataEventArgs e)
        {
            List<object> data = this.MyData;
            var limit = e.Limit;
            if ((e.Start + e.Limit) > data.Count)
            {
                limit = data.Count - e.Start;
            }
            List<object> rangeData = (e.Start < 0 || limit < 0) ? data : data.GetRange(e.Start, limit);
            e.Total = data.Count;
            (sender as Store).DataSource = rangeData;
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:GridPanel ID="GridPanel1" runat="server">
                <Store>
                    <ext:Store runat="server" OnReadData="Store_ReadData" PageSize="3">
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="test" />
                                </Fields>
                            </ext:Model>
                        </Model>
                        <Proxy>
                            <ext:PageProxy>
                                <Reader>
                                    <ext:JsonReader />
                                </Reader>
                            </ext:PageProxy>
                        </Proxy>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column runat="server" Text="Test" DataIndex="test" />
                    </Columns>
                </ColumnModel>
                <BottomBar>
                    <ext:PagingToolbar runat="server" />
                </BottomBar>
            </ext:GridPanel>
        </form>
    </body>
    </html>
  5. #5
    Quote Originally Posted by Daniil View Post
    You can use some dummy data instead of a database. We should be able to copy, paste and run your sample without any changes.

    For example, as you can do with this sample.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <%@ Import Namespace="System.Collections.Generic" %>
    
    <script runat="server">
        public List<object> MyData = new List<object> 
        { 
            new { test = "test1" },
            new { test = "test2" },
            new { test = "test3" },
            new { test = "test4" },
            new { test = "test5" },
            new { test = "test6" },
            new { test = "test7" },
            new { test = "test8" },
            new { test = "test9" }
        };
    
        protected void Store_ReadData(object sender, StoreReadDataEventArgs e)
        {
            List<object> data = this.MyData;
            var limit = e.Limit;
            if ((e.Start + e.Limit) > data.Count)
            {
                limit = data.Count - e.Start;
            }
            List<object> rangeData = (e.Start < 0 || limit < 0) ? data : data.GetRange(e.Start, limit);
            e.Total = data.Count;
            (sender as Store).DataSource = rangeData;
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:GridPanel ID="GridPanel1" runat="server">
                <Store>
                    <ext:Store runat="server" OnReadData="Store_ReadData" PageSize="3">
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="test" />
                                </Fields>
                            </ext:Model>
                        </Model>
                        <Proxy>
                            <ext:PageProxy>
                                <Reader>
                                    <ext:JsonReader />
                                </Reader>
                            </ext:PageProxy>
                        </Proxy>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column runat="server" Text="Test" DataIndex="test" />
                    </Columns>
                </ColumnModel>
                <BottomBar>
                    <ext:PagingToolbar runat="server" />
                </BottomBar>
            </ext:GridPanel>
        </form>
    </body>
    </html>

    This example can work ,if you refresh the gridpanel ,the selected rows are still selected.
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <%@ Import Namespace="System.Collections.Generic" %>
    <script runat="server">
        public List<object> MyData = new List<object> 
        { 
            new {id=1 ,test = "test1" },
            new {id=2 ,test = "test2" },
            new {id=3 ,test = "test3" },
            new {id=4 ,test = "test4" },
            new {id=5 ,test = "test5" },
            new {id=6 ,test = "test6" },
            new {id=7 ,test = "test7" },
         
        };
    
        protected void Store_ReadData(object sender, StoreReadDataEventArgs e)
        {
            List<object> data = this.MyData;
            var limit = e.Limit;
            if ((e.Start + e.Limit) > data.Count)
            {
                limit = data.Count - e.Start;
            }
            List<object> rangeData = (e.Start < 0 || limit < 0) ? data : data.GetRange(e.Start, limit);
            e.Total = data.Count;
            (sender as Store).DataSource = rangeData;
            CheckboxSelectionModel cbm = this.GridPanelPart.SelectionModel.Primary as CheckboxSelectionModel;
            cbm.SelectedRows.Clear();
    
            cbm.UpdateSelection();
    
            //cbm.ClearSelection();
            //cbm.DeselectAll();
    
            //RowSelectionModel sm = this.GridPanelPart.SelectionModel.Primary as RowSelectionModel;
            //sm.SelectedRows.Clear();
            //sm.UpdateSelection();
    
        }
    </script>
    <!DOCTYPE html>
    <html>
    <head id="Head1" runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:GridPanel ID="GridPanelPart" runat="server" Region="Center" Icon="ApplicationViewColumns">
            <Store>
                <ext:Store ID="StorePart" runat="server" RemoteSort="false" OnReadData="Store_ReadData"
                    WarningOnDirty="false">
                    <Proxy>
                        <ext:PageProxy />
                    </Proxy>
                    <Model>
                        <ext:Model ID="Model1" runat="server" IDProperty="id">
                            <Fields>
                                <ext:ModelField Name="id" />
                                <ext:ModelField Name="test" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel ID="ColumnModel1" runat="server">
                <Columns>
                    <ext:RowNumbererColumn ID="RowNumbererColumn1" runat="server" />
                    <ext:Column ID="Column1" runat="server" DataIndex="id" Text="PartID" Width="180" />
                    <ext:Column ID="Column2" runat="server" DataIndex="test" Text="PartCode" Width="180" />
                </Columns>
            </ColumnModel>
            <SelectionModel>
                <ext:CheckboxSelectionModel ID="CheckboxSelectionModel1" runat="server" RowSpan="1"
                    Mode="Multi" />
            </SelectionModel>
            <BottomBar>
                <ext:PagingToolbar ID="PagingToolbar1" runat="server" />
            </BottomBar>
        </ext:GridPanel>
        </form>
    </body>
    </html>
    Click image for larger version. 

Name:	newid.png 
Views:	52 
Size:	11.0 KB 
ID:	8571

    Thank you very much!
  6. #6
    For me the selection is being reset after a refresh. What Ext.NET version are you using?
  7. #7
    Quote Originally Posted by Daniil View Post
    For me the selection is being reset after a refresh. What Ext.NET version are you using?
    version2.1
  8. #8
    Quote Originally Posted by Daniil View Post
    For me the selection is being reset after a refresh. What Ext.NET version are you using?
    Is it also OK when you click the refresh button in the gridpanel? this problem has puzzled me few days. Can you find some ways to solve it in version2.1? Very preciate for your help!
    Last edited by hongxue; Mar 19, 2014 at 7:56 AM.
  9. #9
    I reproduced with v2.1.

    Maybe, you could turn the selection memory functionality at all? This setting for a GridPanel.
    SelectionMemory="false"
    Do you need to maintain the selection across the pages (of PagingToolbar)?
  10. #10
    Quote Originally Posted by Daniil View Post
    I reproduced with v2.1.

    Maybe, you could turn the selection memory functionality at all? This setting for a GridPanel.
    SelectionMemory="false"
    Do you need to maintain the selection across the pages (of PagingToolbar)?
    Yeah, it works. But I need to maintain the selection across the pages .
Page 1 of 4 123 ... LastLast

Similar Threads

  1. Replies: 4
    Last Post: Jul 30, 2013, 5:29 PM
  2. Replies: 2
    Last Post: Jul 30, 2013, 1:44 PM
  3. clear checked rows after reload the grid panel
    By hongxue in forum 2.x Help
    Replies: 0
    Last Post: Jun 20, 2013, 1:38 AM
  4. Replies: 1
    Last Post: Oct 13, 2010, 11:09 PM
  5. how to get checked grid rows values in MVC
    By vs.mukesh in forum 1.x Help
    Replies: 0
    Last Post: Jun 23, 2010, 3:23 PM

Tags for this Thread

Posting Permissions