Grid Selected RowIndex -1 after some row

  1. #1

    Grid Selected RowIndex -1 after some row

    Hi,

    I have a problem on using Checked Grid.
    Here is my grid and a button for counting checked data.
        <ext:GridPanel
            runat="server"
            ID="gridTest"
            ClientIDMode="Static">
            <Store>
                <ext:Store
                    runat="server"
                    ID="storeTest">
                    <Model>
                        <ext:Model runat="server">
                            <Fields>
                                <ext:ModelField Name="name" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel>
                <Columns>
                    <ext:Column runat="server" Text="Name" DataIndex="name" Flex="1" />
                </Columns>
            </ColumnModel>
            <SelectionModel>
                <ext:CheckboxSelectionModel runat="server" Mode="Multi" />
            </SelectionModel>
            <TopBar>
                <ext:Toolbar
                    runat="server">
                    <Items>
                        <ext:Button
                            runat="server"
                            ID="BtnCheck"
                            Text="Check">
                            <DirectEvents>
                                <Click OnEvent="BtnCheck_Click" />
                            </DirectEvents>
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
            </TopBar>
        </ext:GridPanel>
    I fill the grid with 100 data with this code in Page Load event.
            If Not Ext.Net.X.IsAjaxRequest Then
                Dim testData As New List(Of Object())
    
                For i As Integer = 1 To 100
                    testData.Add(New Object() {"Test Data " & i})
                Next
    
                storeTest.DataSource = testData.ToArray()
                storeTest.DataBind()
            End If
    As I mention before, I have a button to counting Checked data.
    Here is my code to count the checked data.
        Protected Sub BtnCheck_Click(sender As Object, e As DirectEventArgs)
            Dim sm As RowSelectionModel = gridTest.GetSelectionModel()
    
            Dim counter As Integer = 0
            Dim counterAll As Integer = 0
            For Each selected As SelectedRow In sm.SelectedRows
                If selected.RowIndex >= 0 Then
                    counter = counter + 1
                End If
    
                counterAll = counterAll + 1
            Next
    
            Ext.Net.X.Msg.Alert("Total Selected", counter & " Check Counted, " & counterAll & " All Checked").Show()
        End Sub
    The problem is, when checked all, even though the data is 100, counterAll is equal to 100 but counter is equal to 53 (maybe different). The Rest of the selected data is not counted because selected.RowIndex equal to -1.
    But this only happen when check all using CTRL+A or check checkbox beside header column. When checking one by one, it works perfectly.

    Click image for larger version. 

Name:	Problem.PNG 
Views:	8 
Size:	28.1 KB 
ID:	24837

    Any idea why this is happen?
    Last edited by Kuro13; Feb 07, 2017 at 3:27 AM.

Similar Threads

  1. How to get rowindex of a gridpanel in JS
    By arjunrvasisht in forum 2.x Help
    Replies: 1
    Last Post: Jan 02, 2015, 3:12 PM
  2. [CLOSED] Selected rowindex is not updated after drag and drop in grid
    By profitsistemas in forum 2.x Premium Help
    Replies: 9
    Last Post: Feb 07, 2013, 4:03 AM
  3. [CLOSED] Get the rowIndex of the selected row
    By 78fede78 in forum 1.x Premium Help
    Replies: 1
    Last Post: Jan 21, 2011, 12:44 PM
  4. [CLOSED] get rowindex for grid
    By idrissb in forum 1.x Premium Help
    Replies: 2
    Last Post: Feb 09, 2010, 3:20 PM
  5. rowIndex in GetRowClass - possible?
    By Tbaseflug in forum 1.x Help
    Replies: 2
    Last Post: Sep 23, 2009, 10:25 PM

Tags for this Thread

Posting Permissions