This is a migrated thread and some comments may be shown as answers.

Get all checked values from GridClientSelectColumn

3 Answers 577 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bruno
Top achievements
Rank 1
Bruno asked on 14 Mar 2012, 12:32 PM
Hi everybody, as my title says, i have a GridClientSelectColumn, on my radGrid, and a button outside this grid, in this button, i try to get all checked check box on this way:
protected void btnDel_Click(object sender, EventArgs e)
{
    string id;
    bool chec;
    foreach (GridDataItem item in RadGrid2.Items)
    {
        CheckBox chk = (CheckBox)item["CheckboxColumn"].Controls[0];
        id = item["codigo"].Text;
        chec= chk.Checked;
    }
}

but if i try this way, i will get one by one valuee from checkbox that are checked.
Exist some way to get ALL rows that my gridClient are selected?
Thankz in advance

<telerik:RadGrid ID="RadGrid2" runat="server" AllowMultiRowSelection="true" Width="300px"
              OnNeedDataSource="RadGrid2_NeedDataSource">
              <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" CommandItemSettings-AddNewRecordText="Novo Registro"
                  CommandItemSettings-RefreshText="Atualizar" DataKeyNames="codigo">
                  <Columns>
                      <telerik:GridClientSelectColumn UniqueName="CheckboxColumn" />
                      <telerik:GridBoundColumn HeaderText="Código" DataField="codigo" UniqueName="codigo" />
                      <telerik:GridBoundColumn HeaderText="Descrição" DataField="descricao" UniqueName="descricao" />
                  </Columns>
              </MasterTableView>
              <ClientSettings EnablePostBackOnRowClick="True">
                  <Selecting AllowRowSelect="true" />
              </ClientSettings>
          </telerik:RadGrid>
      <asp:Button ID="btnDeletar" CommandName="Delete" runat="server"
          Text="Deletar Items" onclick="btnDeletar_Click" />

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 14 Mar 2012, 01:11 PM
Hello,

I guess you want to loop through all selected rows.Check the following code.
C#:
foreach (GridDataItem item in RadGrid2.SelectedItems)
{
    //your code
}

Thanks,
Princy.
0
Bruno
Top achievements
Rank 1
answered on 14 Mar 2012, 01:29 PM
It works for me, thankz!
0
yook
Top achievements
Rank 1
answered on 14 Mar 2017, 04:26 AM

Hi,

I have a rad grid with paging enabled.I select all rows in multiple pages using a GridClientSelectColumn. When I click on print button it prints only the records which are displayed in first page,not all records selected in multiple pages. How to fix it. Plz help...

 

This is how i selected all checkboxes in multiple pages.

 var selected = {};
                function radGridWarehouseUtility_RowSelected(sender, args) {
                    var LID = args.getDataKeyValue("LID");
                    if (!selected[LID]) {
                        selected[LID] = true;
                    }
                }

                function radGridWarehouseUtility_RowDeselected(sender, args) {
                    var LID = args.getDataKeyValue("LID");
                    if (selected[LID]) {
                        selected[LID] = null;
                    }
                }

               function pageLoad() {
                   var dataItems = $find('<%=radGridWarehouseUtility.ClientID %>').get_masterTableView().get_dataItems();
                   for (var i = 0, j = dataItems.length; i < j; i++) {
                       var item = dataItems[i];
                       if (selected[item.getDataKeyValue("LID")]) {
                           item.set_selected(true);
                       }
                   }
               }

 

                        <ClientSettings EnablePostBackOnRowClick="true">
                            <Selecting AllowRowSelect="True"></Selecting>
                            <ClientEvents OnRowSelected="radGridWarehouseUtility_RowSelected"
                                OnRowDeselected="radGridWarehouseUtility_RowDeselected" />
                        </ClientSettings>

 

<telerik:GridClientSelectColumn UniqueName="Select" />

 

code behind...

 

Protected Sub btnPrint_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnPrint.Click

 For Each item As GridDataItem In radGridWarehouseUtility.SelectedItems
            Dim item1 As GridDataItem = item
            Dim chkBox As CheckBox
            chkBox = DirectCast(item1.Item("Select").Controls(0), CheckBox)

            If chkBox.Enabled Then
                Dim lid As String
                lid = CType(radGridWarehouseUtility.MasterTableView.DataKeyValues(item.ItemIndex)("LID"), String)
                qryParams = qryParams & lid & ","
            End If
        Next

End Sub

 

Thanks

Tags
Grid
Asked by
Bruno
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Bruno
Top achievements
Rank 1
yook
Top achievements
Rank 1
Share this question
or