I have a xamdatagrid that uses checkboxes for multi-selections. I can get it to work however whenever the user will click the scrollbar or filter the selected items disappear. Is there a way I can preserve the selected items? Or has there been a fix for it yet?
Hi dvickerie,
When you implemented this, did you follow the information contained inside our blog post on this topic? http://ko.infragistics.com/community/blogs/josh_smith/archive/2008/09/04/adding-checkboxes-to-the-record-selectors-in-xamdatagrid.aspx
I've taken the sample from here and upgraded it to 12.1 to try and reproduce the issue you're experiancing but I'm unable to. Are you implementing this a different way?
I figured out what I was doing wrong and found a fix for that. However my issue I'm having is I've bound IsChecked to the Record.IsSelected:
IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Record.IsSelected, Mode=TwoWay}"
It works fine when the setting CellClickAction="SelectRecord" however the users' dont want to have to double click to edit a records so if I change the setting to EnterEditModeIfAllowed the CTRL and SHIFT functionality no longer works. I tried in the CellActivated event to set the cell.Records.IsSelected to true however that didn't work for me. Unfortauanely the Josh Smith example wouldn't satisfy our needs.
Thank you for providing the sample. I'm able to see what you described about the Ctrl and Shift functionality not working. This is actually by design and it isn't that the functionality no longer works but that selected items are cleared when a cell enters edit mode. That's just the way the grid was designed. That's also the reason why you need to double click when the CellClickAction is set to SelectRecord. Otherwise clicking a row would put a cell in edit mode which would clear the selected records.
Is there a way I can bind the checkbox in the record selector to cell.IsSelected other than Record.IsSelected? When I changed it from Record.IsSelected to Cell.IsSelected in didn't like it.
I've contacted our development team for their feedback on this issue. I'll get back to you shortly once I have a response from them.
While there is no way to bind the checkbox to the Cell.IsSelected directly, you can use an intermediate property which is what development suggests doing. What I mean by this is, add a property to your underlying data object called RecordSelected and bind the checkbox to this. The binding path would be DataItem.RecordSelected.
After the binding has been set, in the SelectedItemsChanged event, determine if a cell has been selected. If it has been selected, get its associated record and then data item. From there you can set the RecordSelected property to true which would update the checkbox.
How can I access the selected cells and change there dataitem value without using a for each loop. The only reason I want to no use a foreach loop is because I'll be dealing with thousands of records (around 10,000) at a time.
Let me know if you have any further questions on this issue.
Let me know if you have any further questions.
Many thanks for your quickly reply.
Issue was resolved as I found the code in the project where right click was restricted to ctrl and shift key, commenting that part has resolved the issue.
@ dvickerie,
I think in the case when the user clicks on a 'Select All' button that it might just be better to loop through XamDataGrid.Records instead of XamDataGrid.SelectedItems.Cells. You're not going to be able to completely avoid looping through cells/records though. Here is a code snippet of what I mean.
if (SelectAll) { foreach (Record rec in xamDataGrid1.Records) { (rec.DataItem as MyDataItem).RecordSelected = true; } } else { foreach (Cell cell in XamDataGrid1.SelectedItems.Cells) { (cell.Record.DataItem as MyDataItem).RecordSelected = true; } }
@ Kartik,
For multiple selection I think you want to use SelectionTypeRecord = "Extended". Do you mean that when you right click that you are losing your selected records? This shouldn't be the case as I've tested this and after selecting multiple rows, right-clicking does not clear or modify the currently selected records. Which version of NetAdvantage are you using?
HI,
We are facing one issue with XamDataGrid.
User Action - User goes to particular screen do select multiple rows and then right click to do some action on them.
Problem description: User is required to hold control or shift key to select multiple record if he does not select these control then after right click few records are left selected.
From our side we have set SelectionTypeField = "Extended", Please help us to solve this issue as this some time really annoying for the end user.
Please note similar action works perfectly in WinGrid.
Thanks
Kartik Chhabra