[FROM CheckBoxRowSelect - Selection is cleared when you click outside of a check box column]
Hi,
my scenario is much more different because I'm using pagination.
When I change page, I have to keep previous selections.
Now, when I use clearselection method inside masterowexpanded event, also previous selection will be cleared.
Is there any workaround?
Thanks in advance.
Sly
Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Detail views are re-created each time you expand them. It also implies that their selection will be cleared, except the first row (see the attached video). Thus, it is not quite clear what selection you don't want to lose. Do you have code that saves selection for detail views and restores it on expansion? If so, you can check, for instance, whether only the first row is selected and clear the selection:
Private Sub gridView1_MasterRowExpanded(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Grid.CustomMasterRowEventArgs) Dim detailView As GridView = TryCast(gridView1.GetDetailView(e.RowHandle, e.RelationIndex), GridView) Dim rows() As Integer = detailView.GetSelectedRows() If rows.Length = 1 AndAlso rows(0) = 0 Then detailView.ClearSelection() End If End Sub
To give you a more precise answer, we need to better understand your scenario. Would you please clarify what selection you want to preserve? This information will allow us to find an appropriate solution faster.
I hope to receive your response soon.
Hi,
thanks for your attention.
When I select one row, master or detail either, I conserve selected object on current selected list.
When I change page, I select row if it is contained in selected list, for preserve user selection.
Now current issue is:
if expand one row, automatically first detail row is selected and added to the selected list. But this is not a user choice.
In the MasterRowExpanded event:
If Me.pSelectedConsortia IsNot Nothing AndAlso Me.pSelectedConsortia.Count > 0 Then
For j As Integer = 0 To detailView.RowCount - 1
…
'if current row it's contained in selected list
detailView.SelectRow(j)
…
Next
Else
detailView.BeginSelection()
detailView.ClearSelection()
detailView.EndSelection()
End If
In my code, I know it's a user choice only if row is contained in selected list. In your example code, the user choice is given only if row is selected in detail view. It's quite different.
I hope you understand my effective problem.
Thanks in advance
Sly
>>if expand one row, automatically first detail row is selected and added to the selected list.
You're right, Silvestro. The CheckBoxRowSelection feature was initially designed for a single view only and due to master-detail specifics the first detail row is selected by default when a master row is expanded. If this behavior doesn't meet your requirements (I mean, you're unable to determine whether or not this row is selected by the end-user), I suggest implementing a similar functionality manually. Use the helper class from the Multiple selection using checkbox (web style) example as a basis. This way, you can customize the selection logic as your needs dictate and be sure that nothing is selected unless it was made explicitly.
Let us know if we can be of more help.