Hi,
When I add a new record to my grid, that record is not selectable again, yet the records that were filled upon loading the grid are selectable. There is a protected property call IsSelectable. My old records return true for this property, but my new records return false after I have added the record. Specifically, when the RecordUpdating event is fired the rnew ecord is selectable, when the RecordUpdated event is fired that record is no longer selectable (the property returns false). The documentation is quite sparse for this property, "Returns true only if the record can be selected" is the extent of the documentation. What determines the selectabiity of a record? Why would the initial records be selectable but the added records not be?
Thanks for your help!
TJ
Hi Joe,
Thanks for your quick response!
I will show you what I am doing. I have an AddRecord row fixed at the top. It consists of two visible fields and two collapsed fields. The first field is implemented as a ComboBox (using XAML virtually identical to code in the documentation). When I select an item in the combobox (which corresponsds to the ControlName field, I then fill in the rest of the fields, and set the other visible field as active in case the user wants to change it:
{
ControlRecordWithControlTypeName item = (sender as ComboBox).SelectedItem as ControlRecordWithControlTypeName; if (item == null)return; _addRecord.Cells["ControlName"].Value = item.ControlName;_addRecord.Cells["ControlID"].Value = item.ControlID; _addRecord.Cells["ControlTypeName"].Value = item.ControlTypeName;_addRecord.Cells["ControlTypeID"].Value = item.ControlTypeID;_addRecord.Cells["ControlTypeName"].IsActive = true;
if (item == null)
_addRecord.Cells["ControlName"].Value = item.ControlName;
_addRecord.Cells["ControlTypeName"].Value = item.ControlTypeName;
}
When I hit Enter, and the record is updated the IsSelectable property changes from true to false between the RecordUpdating event and the RecordUpdated event.
For completeness I will show you the XAML for the grid (I will leave out the fields, they all have AllowEdit=true and AllGroupBy=false:
<grid:XamDataGrid Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="20,30,20,2" Name="dgControls" MinWidth="400" MinHeight="100" DataSource="{Binding Source={StaticResource CRWithCTName}}" InitializeRecord="dgControls_InitializeRecord" IsEnabled="True" InitializeTemplateAddRecord="dgControls_InitializeTemplateAddRecord" AutoFit="True" IsNestedDataDisplayEnabled="False" RecordActivated="dgControls_RecordActivated" RecordDeactivating="dgControls_RecordDeactivating" UpdateMode="OnUpdate" RecordUpdating="dgControls_RecordUpdating" RecordUpdated="dgControls_RecordUpdated">
<grid:XamDataGrid.FieldLayoutSettings>
<grid:FieldLayoutSettings AllowAddNew="True" AllowDelete="True" AddNewRecordLocation="OnTopFixed" HighlightAlternateRecords="True" DataRecordSizingMode="SizedToContentAndIndividuallySizable" AutoGenerateFields="False" SelectionTypeRecord="Single"/>
</grid:XamDataGrid.FieldLayoutSettings> ... field information...
</grid:XamDataGrid.FieldLayoutSettings>
... field information...
The RecordActivate and Update events are only used to observe the state of the record and don't perform any function.
The InitializeTermplateAddRecord event does the following:
if (_addRecord != null) { _addRecord.Cells["ControlName"].EditAsType = typeof(string); _addRecord.Cells["ControlName"].EditorStyle = null; } _addRecord = e.TemplateAddRecord; //cboControlNameEditor is the combobox for column one. It is almost a direct copy of the example in your doumentation _addRecord.Cells["ControlName"].EditorStyle = FindResource("cboControlNameEditor") as Style;
_addRecord.Cells["ControlName"].EditAsType = typeof(string); _addRecord.Cells["ControlName"].EditorStyle = null;
_addRecord.Cells["ControlName"].EditorStyle = null;
_addRecord = e.TemplateAddRecord;
//cboControlNameEditor is the combobox for column one. It is almost a direct copy of the example in your doumentation
_addRecord.Cells["ControlName"].EditorStyle = FindResource("cboControlNameEditor") as Style;
I hope this gives you enough information.
Thanks for your help,