SelectedRows

4 posts, 0 answers
  1. Mauricio
    Mauricio avatar
    3 posts
    Member since:
    Nov 2011

    Posted 30 Nov 2011 Link to this post

    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.
  2. Alexander
    Admin
    Alexander avatar
    306 posts

    Posted 05 Dec 2011 Link to this post

    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.

  3. Mauricio
    Mauricio avatar
    3 posts
    Member since:
    Nov 2011

    Posted 05 Dec 2011 Link to this post

    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!
  4. Alexander
    Admin
    Alexander avatar
    306 posts

    Posted 06 Dec 2011 Link to this post

    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.

Back to Top