[CLOSED] Checkbox Selection Model paging issue

  1. #1

    [CLOSED] Checkbox Selection Model paging issue

    Hi,

    Can anyone help on below?

    I would like to prevent listener (select / deselect ) to be fired when paging changes with checkbox selection model.

    If I select few or all records on page 1 and move to page 2, the select /deselect listener must not fired implicitly. I have some logic in both listener which I want it should execute explicitly when user select or deselect on checkbox.
    Last edited by Daniil; Jan 17, 2014 at 11:24 AM. Reason: [CLOSED]
  2. #2
    Hi @shaileshsakaria,

    Please clarify, along with your requirement, do you still need maintaining selection across the pages?
  3. #3
    Please see the below code where,

    User has given choice to select pcs & cts as per his choices. We need to show the selection summary at the bottom. The problem is when we move on next page, the deselect event of checkboxselection model fires and hence summary gets reset!

    You can please check the below record, select few records on page one, you will find summary at bottom. move to second page and you will see summary gets reset due to deselect listener. I want deselect should fire only explicitly when user uncheck and not during paging.

    Request you to please asist.

    <script runat="server">
    
     public class StoneMst_Temp
            {
                public int StoneID { get; set; }
                public string DisplayStoneID { get; set; }
                public int Pcs { get; set; }
                public decimal Cts { get; set; }
                public decimal FinalRate { get; set; }
                public decimal FinalDiscount { get; set; }
                public decimal FinalAmount { get; set; }
    
                public StoneMst_Temp(int stoneID, string displayStoneId, int pcs, int cts, decimal finalRate, decimal finalDiscount, decimal finalAmount)
                {
                    StoneID = stoneID;
                    DisplayStoneID = displayStoneId;
                    Pcs = pcs;
                    Cts = cts;
                    FinalRate = finalRate;
                    FinalDiscount = finalDiscount;
                    FinalAmount = finalAmount;
                }
            }
            
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!X.IsAjaxRequest)
                {
                    BindStore();
                }
            }
            public void BindStore()
            {
                StoreStoneMst.DataSource = new List<StoneMst_Temp>();
                StoreStoneMst.DataBind();
               
            }
    
            protected void StoneMst_ReadData(object sender, StoreReadDataEventArgs e)
            {
                try
                {
                    List<StoneMst_Temp> lstStoneMstDet = new List<StoneMst_Temp>();
                    lstStoneMstDet.Add(new StoneMst_Temp(10001,"Test10001",1,2,5410,58,2272));
                    lstStoneMstDet.Add(new StoneMst_Temp(10002, "Test10002", 1, 9, 5898, 19, 4777));
                    lstStoneMstDet.Add(new StoneMst_Temp(10003, "Test10003", 1, 10, 1409, 45, 775));
                    lstStoneMstDet.Add(new StoneMst_Temp(10004, "Test10004", 1, 8, 8431, 32, 5733));
                    lstStoneMstDet.Add(new StoneMst_Temp(10005, "Test10005", 1, 5, 925, 10, 833));
                    lstStoneMstDet.Add(new StoneMst_Temp(10006, "Test10006", 1, 7, 5553, 21, 4387));
                    lstStoneMstDet.Add(new StoneMst_Temp(10007, "Test10007", 1, 6, 4815, 55, 2167));
                    lstStoneMstDet.Add(new StoneMst_Temp(10008, "Test10008", 1, 10, 518, 4, 497));
                    lstStoneMstDet.Add(new StoneMst_Temp(10009, "Test10009", 1, 0, 8461, 69, 2623));
                    lstStoneMstDet.Add(new StoneMst_Temp(10010, "Test10010", 1, 4, 3042, 35, 1977));
                    lstStoneMstDet.Add(new StoneMst_Temp(10011, "Test10011", 1, 3, 6531, 89, 718));
                    lstStoneMstDet.Add(new StoneMst_Temp(10012, "Test10012", 1, 1, 2339, 10, 2105));
                    lstStoneMstDet.Add(new StoneMst_Temp(10013, "Test10013", 1, 4, 2646, 87, 344));
                    lstStoneMstDet.Add(new StoneMst_Temp(10014, "Test10014", 1, 4, 2147, 32, 1460));
                    lstStoneMstDet.Add(new StoneMst_Temp(10015, "Test10015", 1, 9, 2008, 30, 1406));
                    lstStoneMstDet.Add(new StoneMst_Temp(10016, "Test10016", 1, 8, 5101, 8, 4693));
                    lstStoneMstDet.Add(new StoneMst_Temp(10017, "Test10017", 1, 2, 7085, 59, 2905));
                    lstStoneMstDet.Add(new StoneMst_Temp(10018, "Test10018", 1, 4, 720, 21, 569));
                    lstStoneMstDet.Add(new StoneMst_Temp(10019, "Test10019", 1, 3, 433, 11, 385));
                    lstStoneMstDet.Add(new StoneMst_Temp(10020, "Test10020", 1, 3, 4893, 66, 1664));
                    lstStoneMstDet.Add(new StoneMst_Temp(10021, "Test10021", 1, 10, 8745, 71, 2536));
                    lstStoneMstDet.Add(new StoneMst_Temp(10022, "Test10022", 1, 6, 2721, 67, 898));
                    lstStoneMstDet.Add(new StoneMst_Temp(10023, "Test10023", 1, 1, 6354, 29, 4511));
                    lstStoneMstDet.Add(new StoneMst_Temp(10024, "Test10024", 1, 4, 7747, 72, 2169));
                    lstStoneMstDet.Add(new StoneMst_Temp(10025, "Test10025", 1, 8, 7594, 19, 6151));
                    lstStoneMstDet.Add(new StoneMst_Temp(10026, "Test10026", 1, 2, 3271, 76, 785));
                    lstStoneMstDet.Add(new StoneMst_Temp(10027, "Test10027", 1, 9, 6090, 74, 1583));
                    lstStoneMstDet.Add(new StoneMst_Temp(10028, "Test10028", 1, 9, 44, 33, 29));
                    lstStoneMstDet.Add(new StoneMst_Temp(10029, "Test10029", 1, 8, 8879, 42, 5150));
                    lstStoneMstDet.Add(new StoneMst_Temp(10030, "Test10030", 1, 0, 9279, 21, 7330));
                    lstStoneMstDet.Add(new StoneMst_Temp(10031, "Test10031", 1, 6, 6916, 2, 6778));
                    lstStoneMstDet.Add(new StoneMst_Temp(10032, "Test10032", 1, 7, 9102, 1, 9011));
                    lstStoneMstDet.Add(new StoneMst_Temp(10033, "Test10033", 1, 1, 2728, 8, 2510));
                    lstStoneMstDet.Add(new StoneMst_Temp(10034, "Test10034", 1, 9, 3732, 17, 3098));
                    lstStoneMstDet.Add(new StoneMst_Temp(10035, "Test10035", 1, 2, 6371, 23, 4906));
                    lstStoneMstDet.Add(new StoneMst_Temp(10036, "Test10036", 1, 5, 3182, 94, 191));
                    lstStoneMstDet.Add(new StoneMst_Temp(10037, "Test10037", 1, 5, 3155, 9, 2871));
                    lstStoneMstDet.Add(new StoneMst_Temp(10038, "Test10038", 1, 5, 8537, 58, 3586));
                    lstStoneMstDet.Add(new StoneMst_Temp(10039, "Test10039", 1, 6, 7238, 21, 5718));
                    lstStoneMstDet.Add(new StoneMst_Temp(10040, "Test10040", 1, 9, 8813, 14, 7579));
                    lstStoneMstDet.Add(new StoneMst_Temp(10041, "Test10041", 1, 9, 3900, 27, 2847));
                    lstStoneMstDet.Add(new StoneMst_Temp(10042, "Test10042", 1, 3, 2745, 17, 2278));
                    lstStoneMstDet.Add(new StoneMst_Temp(10043, "Test10043", 1, 2, 2710, 69, 840));
                    lstStoneMstDet.Add(new StoneMst_Temp(10044, "Test10044", 1, 8, 261, 72, 73));
                    lstStoneMstDet.Add(new StoneMst_Temp(10045, "Test10045", 1, 7, 3502, 81, 665));
                    lstStoneMstDet.Add(new StoneMst_Temp(10046, "Test10046", 1, 7, 8581, 83, 1459));
                    lstStoneMstDet.Add(new StoneMst_Temp(10047, "Test10047", 1, 9, 9336, 27, 6815));
                    lstStoneMstDet.Add(new StoneMst_Temp(10048, "Test10048", 1, 10, 5168, 76, 1240));
                    lstStoneMstDet.Add(new StoneMst_Temp(10049, "Test10049", 1, 5, 1354, 53, 636));
                    lstStoneMstDet.Add(new StoneMst_Temp(10050, "Test10050", 1, 4, 9179, 60, 3672));
                    lstStoneMstDet.Add(new StoneMst_Temp(10051, "Test10051", 1, 5, 2020, 5, 1919));
                    lstStoneMstDet.Add(new StoneMst_Temp(10052, "Test10052", 1, 10, 4338, 32, 2950));
                    lstStoneMstDet.Add(new StoneMst_Temp(10053, "Test10053", 1, 2, 9575, 39, 5841));
                    lstStoneMstDet.Add(new StoneMst_Temp(10054, "Test10054", 1, 2, 9380, 45, 5159));
                    lstStoneMstDet.Add(new StoneMst_Temp(10055, "Test10055", 1, 5, 5945, 67, 1962));
                    lstStoneMstDet.Add(new StoneMst_Temp(10056, "Test10056", 1, 3, 5364, 19, 4345));
                    lstStoneMstDet.Add(new StoneMst_Temp(10057, "Test10057", 1, 2, 3801, 73, 1026));
                    lstStoneMstDet.Add(new StoneMst_Temp(10058, "Test10058", 1, 2, 8492, 70, 2548));
                    lstStoneMstDet.Add(new StoneMst_Temp(10059, "Test10059", 1, 4, 2263, 50, 1132));
                    lstStoneMstDet.Add(new StoneMst_Temp(10060, "Test10060", 1, 5, 4664, 37, 2938));
                    lstStoneMstDet.Add(new StoneMst_Temp(10061, "Test10061", 1, 9, 1048, 39, 639));
                    lstStoneMstDet.Add(new StoneMst_Temp(10062, "Test10062", 1, 5, 1114, 54, 512));
                    lstStoneMstDet.Add(new StoneMst_Temp(10063, "Test10063", 1, 7, 8861, 62, 3367));
                    lstStoneMstDet.Add(new StoneMst_Temp(10064, "Test10064", 1, 6, 1267, 87, 165));
                    lstStoneMstDet.Add(new StoneMst_Temp(10065, "Test10065", 1, 5, 1738, 80, 348));
                    lstStoneMstDet.Add(new StoneMst_Temp(10066, "Test10066", 1, 9, 9917, 9, 9024));
                    lstStoneMstDet.Add(new StoneMst_Temp(10067, "Test10067", 1, 2, 2028, 66, 690));
                    lstStoneMstDet.Add(new StoneMst_Temp(10068, "Test10068", 1, 1, 9889, 17, 8208));
                    lstStoneMstDet.Add(new StoneMst_Temp(10069, "Test10069", 1, 2, 6076, 1, 6015));
                    lstStoneMstDet.Add(new StoneMst_Temp(10070, "Test10070", 1, 5, 3581, 49, 1826));
                    lstStoneMstDet.Add(new StoneMst_Temp(10071, "Test10071", 1, 1, 9694, 18, 7949));
                    lstStoneMstDet.Add(new StoneMst_Temp(10072, "Test10072", 1, 7, 9614, 72, 2692));
                    lstStoneMstDet.Add(new StoneMst_Temp(10073, "Test10073", 1, 3, 5437, 97, 163));
                    lstStoneMstDet.Add(new StoneMst_Temp(10074, "Test10074", 1, 6, 8636, 60, 3454));
                    lstStoneMstDet.Add(new StoneMst_Temp(10075, "Test10075", 1, 6, 1873, 31, 1292));
                    lstStoneMstDet.Add(new StoneMst_Temp(10076, "Test10076", 1, 7, 9501, 44, 5321));
                    lstStoneMstDet.Add(new StoneMst_Temp(10077, "Test10077", 1, 8, 9936, 3, 9638));
                    lstStoneMstDet.Add(new StoneMst_Temp(10078, "Test10078", 1, 2, 4096, 70, 1229));
                    lstStoneMstDet.Add(new StoneMst_Temp(10079, "Test10079", 1, 1, 491, 40, 295));
                    lstStoneMstDet.Add(new StoneMst_Temp(10080, "Test10080", 1, 7, 5828, 55, 2623));
                    lstStoneMstDet.Add(new StoneMst_Temp(10081, "Test10081", 1, 3, 9060, 75, 2265));
    
    
                    gridStoneMst.GetStore().DataSource = this.BaseGridPaging<StoneMst_Temp>(lstStoneMstDet, e, gridStoneMst, ref cmbSinglePaging);
    
                }
                catch (Exception ex)
                {
                    base.ShowException(ex, StaticMethod.TTEnum.ExceptionType.Error);
                }
            }
    
            public List<T> BaseGridPaging<T>(List<T> data, StoreReadDataEventArgs e, GridPanel grid, ref ComboBox comboBox1)
            {
                int start = e.Start;
                int limit = e.Limit;
                int pageIndex = e.Page;
                int pageSize = grid.GetStore().PageSize;
                if (comboBox1.SelectedItem != null && !string.IsNullOrEmpty(comboBox1.SelectedItem.Value))
                {
                    pageSize = Convert.ToInt32(comboBox1.SelectedItem.Value);
                    grid.GetStore().PageSize = pageSize;
                    start = (pageIndex - 1) * pageSize;
                    limit = pageSize;
                }
                e.Total = data.Count;
                if ((start + limit) > data.Count)
                    limit = data.Count - start;
                return data = (start < 0 || limit < 0) ? data : data.GetRange(start, limit);
            }
    
    </script>
    <script>
            var cloneStore;
            var copyStoreStructure = function (source) {
                if (cloneStore == undefined) {
                    //cloneStore = new Ext.data.Store({ storeId: 'cloneStore', fields: source.reader.meta.fields });
                    cloneStore = Ext.create('Ext.data.Store', {
                        model: Ext.ModelManager.getModel(source.model),
                        autoLoad: false
                    });
                    cloneStore.removeAll();
                    cloneStore.commitChanges();
                }
            }
    
            var getSummary = function () {
                if (cloneStore != undefined) {
                    App.txtTotPcs.setValue(0);
                    App.txtTotCts.setValue(0);
                    App.txtTotPrice.setValue(0);
                    var totPcs = 0; var totCts = 0.0; var totPrice = 0.0;
                    for (var i = 0; i != cloneStore.data.length; i++) {
                        totPcs += cloneStore.getAt(i).data.Pcs != null ? cloneStore.getAt(i).data.Pcs : 0;
                        totCts += cloneStore.getAt(i).data.Cts != null ? cloneStore.getAt(i).data.Cts : 0;
                        totPrice += cloneStore.getAt(i).data.FinalAmount != null ? cloneStore.getAt(i).data.FinalAmount : 0;
                    }
                    App.txtTotPcs.setValue(totPcs);
                    App.txtTotCts.setValue(totCts);
                    App.txtTotPrice.setValue(totPrice);
                }
            }
        </script>
       
    
        <ext:GridPanel ID="gridStoneMst" runat="server" Title="Stone Master" RowLines="true" ColumnLines="true" Height="350" IDMode="Static">
            <Store>
                <ext:Store ID="StoreStoneMst" runat="server" IDMode="Static" OnReadData="StoneMst_ReadData" PageSize="10">
                    <Proxy>
                        <ext:PageProxy />
                    </Proxy>
                    <Model>
                        <ext:Model ID="ModelStoneMst" runat="server" IDProperty="StoneID">
                            <Fields>
                                <%-- <ext:ModelField Name="IsSelected" Type="Boolean" DefaultValue="false" />--%>
                                <ext:ModelField Name="StoneID" />
                                <ext:ModelField Name="DisplayStoneID" />
                                <ext:ModelField Name="Pcs" />
                                <ext:ModelField Name="Cts" />
                                <ext:ModelField Name="FinalRate" />
                                <ext:ModelField Name="FinalDiscount" />
                                <ext:ModelField Name="FinalAmount" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel>
                <Columns>
                    <ext:RowNumbererColumn ID="rowColumn1" runat="server" Width="50" Text="#" />           
                    <ext:Column ID="colStoneID" runat="server" Text="Stone<br>Unique ID" DataIndex="StoneID" />
                    <ext:Column ID="colDisplayStone" runat="server" Text="DisplayStone" DataIndex="DisplayStoneID" />
                    <ext:SummaryColumn ID="sumColPcs" runat="server" Text="PCS" Align="Right" SummaryType="Sum" DataIndex="Pcs">
                        <Renderer Handler="return Ext.util.Format.number(value,'0.00')" />
                        <SummaryRenderer Handler="return Ext.util.Format.number(value,'0.00')" />
                    </ext:SummaryColumn>
                    <ext:SummaryColumn ID="sumColCts" runat="server" Text="Cts" Align="Right" SummaryType="Sum" DataIndex="Cts">
                        <Renderer Handler="return Ext.util.Format.number(value,'0.00')" />
                        <SummaryRenderer Handler="return Ext.util.Format.number(value,'0.00')" />
                    </ext:SummaryColumn>
                    <ext:SummaryColumn ID="sumColFinalRate" runat="server" Text="Final Rate" Align="Right" SummaryType="Sum" DataIndex="FinalRate">
                        <Renderer Handler="return Ext.util.Format.number(value,'0.00')" />
                        <SummaryRenderer Handler="return Ext.util.Format.number(value,'0.00')" />
                    </ext:SummaryColumn>
                    <ext:SummaryColumn ID="sumColFinalDiscount" runat="server" Text="Final Disc%" Align="Right" SummaryType="Sum" DataIndex="FinalDiscount">
                        <Renderer Handler="return Ext.util.Format.number(value,'0.00')" />
                        <SummaryRenderer Handler="return Ext.util.Format.number(value,'0.00')" />
                    </ext:SummaryColumn>
                    <ext:SummaryColumn ID="sumColFinalAmount" runat="server" Text="Final Amout" Align="Right" SummaryType="Sum" DataIndex="FinalAmount">
                        <Renderer Handler="return Ext.util.Format.number(value,'0.00')" />
                        <SummaryRenderer Handler="return Ext.util.Format.number(value,'0.00')" />
                    </ext:SummaryColumn>
                </Columns>
            </ColumnModel>
            <Features>
                <ext:Summary ID="sum1" runat="server"></ext:Summary>
            </Features>
            <BottomBar>
                <ext:PagingToolbar ID="SinglePaging" runat="server" IDMode="Static">
                    <Items>
                        <ext:ComboBox ID="cmbSinglePaging" runat="server" Width="80" IDMode="Static" />
                    </Items>
                </ext:PagingToolbar>
            </BottomBar>
            <Plugins>
            </Plugins>
            <SelectionModel>
                <ext:CheckboxSelectionModel ID="chkModel" runat="server">
                    <Listeners>
                        <Select Handler="copyStoreStructure(#{StoreStoneMst}); cloneStore.add(record); cloneStore.commitChanges();getSummary();">
                        </Select>  
                        <Deselect Handler="alert('Deselect fired'); cloneStore.remove(record); cloneStore.commitChanges();getSummary();">
                        </Deselect>
                    </Listeners>
                </ext:CheckboxSelectionModel>
                <%--<ext:RowSelectionModel ID="rwModel" runat="server" Mode="Multi">
                </ext:RowSelectionModel>--%>
            </SelectionModel>
        </ext:GridPanel>
    
        <ext:FormPanel ID="FormSummary" runat="server" Title="User Selection" Layout="HBoxLayout" Frame="true">
            <Items>
                <ext:Component Width="10" Height="10" runat="server" ID="comp1" />
                <ext:NumberField ID="txtTotPcs" runat="server" ReadOnly="true" FieldLabel="Total Pcs" IDMode="Static" />
                <ext:NumberField ID="txtTotCts" runat="server" ReadOnly="true" FieldLabel="Total Cts" IDMode="Static" />
                <ext:NumberField ID="txtTotPrice" runat="server" ReadOnly="true" FieldLabel="Total Price" IDMode="Static" />
                
            </Items>
        </ext:FormPanel>
    </asp:Content>
  4. #4
    I cannot reproduce. Probably, it has been fixed. Please clarify what Ext.NET version are you using?

Similar Threads

  1. Replies: 1
    Last Post: Dec 04, 2013, 10:53 AM
  2. Replies: 10
    Last Post: Apr 19, 2013, 3:16 PM
  3. [CLOSED] Row Editor issue with Checkbox selection model
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Dec 07, 2011, 5:12 PM
  4. Replies: 2
    Last Post: Aug 09, 2011, 10:38 AM
  5. Replies: 4
    Last Post: Oct 06, 2010, 9:08 AM

Posting Permissions