I am using a converter (below) and CVP to identify text patterns in a particular column in my grid. When I find a matching entry, I want to modify it in the recordset and refresh or affect the view such that the modified version is displayed. E.G. If rox x column n contains "Fred" change to "Barney" etc.
Questions: Is this a sound approach? Is it possible to modify the record at run time and display the new value without reloading the whole thing? Can I pass the whole record or key fields via the CVP rather than just the field it is acting on?
I've attached the converter so you can get the idea of what I am trying to do. Below you can see I am scanning the Area name (looking for pattern) and attaching it to the UnitID field. The CVP returns the Area name to the converter. I would like to return the unitid also so I can use it to update the recordset (it is the key).
Thanks,
Glenn
<areaConverter:DuplicateAreaConverter x:Key="conv"/>
<Style x:Key="filterAreaFieldValues" TargetType="{x:Type igDP:CellValuePresenter}"> <Style.Triggers> <!-- RTO Edit Rule--> <DataTrigger Binding="{Binding Path=Field.Name, RelativeSource={RelativeSource Self}}" Value="UnitID"> <Setter Property="IsEnabled"> <Setter.Value> <Binding Converter="{StaticResource conv}" Path="Record.Cells[Area].Value" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type igDP:DataRecordPresenter}}"/> </Setter.Value> </Setter> </DataTrigger> </Style.Triggers> </Style>
Hello Glenn,
I believe if you try using the InitializeRecord event, this will simplify things and will reflect the changes immediately. The InitializeRecord fires once a records is initialized or reinitialized. In the event args you have e.ReInitialize which you can use. You will need to iterate through the cells and make the appropriate changes.
InitializeRecord would also fire when a value of a cell changes, so that you can keep your data synchronized.
Thanks Alex,
Yes, that seems to be the correct location for the change. I added the below to test. The code works fine but the view is not updated. Am I missing something? Do I need to go back to the recordset?
void AreaUnitDetails_InitializeRecord(object sender, Infragistics.Windows.DataPresenter.Events.InitializeRecordEventArgs e) { Infragistics.Windows.DataPresenter.Record[] gbr; gbr = this.AreaUnitDetails.GetRecordsInView(false);
try { foreach (Infragistics.Windows.DataPresenter.Record rec in gbr) { if (((ASEngine.BusinessObjects.Entities.UnitDetail)(((Infragistics.Windows.DataPresenter.DataRecord)(rec)).Cells.Record.DataItem)).Area.ToString() == "RTO-R|RFC-SR") { ((ASEngine.BusinessObjects.Entities.UnitDetail)(((Infragistics.Windows.DataPresenter.DataRecord)(rec)).Cells.Record.DataItem)).Area = null; ((ASEngine.BusinessObjects.Entities.UnitDetail)(((Infragistics.Windows.DataPresenter.DataRecord)(rec)).Cells.Record.DataItem)).Area = "RTO-R"; } } } catch (Exception ex) { Logger.LogException(LogSourceType.ClientApplication, ex); } }
The XamDataGrid should automatically do that. Have you implemented INotifyPropertyChanged interface to the underlying class?