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

SelectedRows

3 Answers 156 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mauricio
Top achievements
Rank 1
Mauricio asked on 30 Nov 2011, 11:25 PM
Hi, everyone,

I have been using telerik controls for windows for few months now, and this may be a stupid question. I've noticed that when a radgrid has been filtered or sorted, the SelectedRows property shows only one row selected even though more than one has been selected. I had a piece of code that uses that property so that on the edition of one row the value is copied to the other rows.

Here's a sample of my code:

Private Sub rgvContractDetails_CellEndEdit(sender As Object, e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles rgvContractDetails.CellEndEdit
   Try
 
      If rgvContractDetails.SelectedRows.Count > 1 Then
 
         Select Case e.Column.Name
            Case "Quantity"
               For Each Row As GridViewRowInfo In rgvContractDetails.SelectedRows
                  Dim oSelectedItem As SalesContractDetail = Row.DataBoundItem
                  Row.Cells("Quantity").Value = e.Value
                  oSelectedItem.QuantityStr = e.Value
                  oSelectedItem.CalculateBalance()
                  Row.Cells("QtyBalance").Value = oSelectedItem.BalanceStr
               Next
            Case "QtyCancel"
               For Each Row As GridViewRowInfo In rgvContractDetails.SelectedRows
                  Dim oSelectedItem As SalesContractDetail = Row.DataBoundItem
                  Row.Cells("QtyCancel").Value = e.Value
                  oSelectedItem.CancelStr = e.Value
                  oSelectedItem.CalculateBalance()
                  Row.Cells("QtyBalance").Value = oSelectedItem.BalanceStr
                  Row.Cells("CancelDate").Value = Today.ToShortDateString
               Next
      End If
 
   Catch ex As Exception
      MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
   End Try
End Sub


Is this the default behavior? If so, is there a workaround so that I can persist the selected rows programmatically and keep my code as it is?  I am using version 2011.02.712.

Thanks for your help,

Mauricio.

3 Answers, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 05 Dec 2011, 02:23 PM
Hello Mauricio,

Thank you for your question.

I tested the scenario you describe and I confirm that RadGridView loses the multiple selected rows when it has a sorted column and a cell value is edited. I added this issue to our PITS and updated your Telerik points for reporting it. We will address the issue in a future release.

I was not able to reproduce the issue regarding the filtered RadGridView.

Best regards,
Alexander
the Telerik team

Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

0
Mauricio
Top achievements
Rank 1
answered on 05 Dec 2011, 02:42 PM
Thank you for your response. You are definitely right about the filtering issue, It was my mistake. I have no problem when filtering and I'm looking forward for your next release.

Thanks again!
0
Alexander
Telerik team
answered on 06 Dec 2011, 03:58 PM
Hello Mauricio,

I could suggest a workaround for the MultiSelect sorting issue - the selected rows are lost when RadGridView raises the CellEndEdit, event but not when the control raises the CellBeginEdit event. You can get the selected rows in a CellBeginEdit event handler and use them in the CellEndEdit event handler.

I hope it helps.

Best regards,
Alexander
the Telerik team

Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

Tags
GridView
Asked by
Mauricio
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Mauricio
Top achievements
Rank 1
Share this question
or