Hi all
My records contain unbound cells which display data based on on a presenter style and a converter. For these cells, the grid is not aware if the underlying data changes - which results in a faulty representation of my data. What I'm looking for is a way to refresh a record according to the functionality provided by WinGrid. I'm pretty sure there must be something, but I couldn't figure out where...
Thanks for your advice
Philipp
ps: I think this problem is one of the shortcomings of the BindingPath string of an unbound field. It sure would be nice if we just could use a real binding instead:<igDP:UnboundField Value="{Binding ...}" />
Hi Philipp,
I am not sure if this will help but I had the refresh problem on the grid too when the underlying data that it is bound to changed. So, I had to set the DataSource to null and set it back again to fix my problem.
Regards,
MW
MW,
Thats not really an option for me - reloading the whole data source would remarkably degrade performance as I'll be dealing with rather big collections. However, I still think there must be (or at the very least, should be ) a way to refresh a single record.
Cheers!
Hi Joe
Thanks - once more - for your feedback. I'm aware of the automatic refresh (which makes perfectly sense), but in my case, none of this applies. It's just a converter of my style that would return a different value if it got re-evaluated. This is why I wanted to trigger a refresh manually. Is there no way to do this?
Regarding the binding string: I don't understand how I could this make more flexible (without reverting to a cell value presenter). As a short example:
<igDP:UnboundField BindingPath="{Binding Source={XXX}, Path=FirstName}" />
This binding expression will be resolved before it is being processed by the grid. So in case the binding returns "John" (which would be a value I'd like to see), WinGrid tries to bind the cell to a property named "John" rather than displaying the value.
Cheers,
CellValuePresenter myCellValuePresenter = CellValuePresenter.FromRecordAndField(myDataRecord, myField);
myCellValuePresenter.CoerceValue(CellValuePresenter.ValueProperty;
Hello Joe
<igDP:UnboundField Name="EditStatus" Label="" BindingPath="IsDirty"> <igDP:Field.Settings> <igDP:FieldSettings AllowEdit="False" CellClickAction="SelectRecord" CellValuePresenterStyle="{StaticResource Grid_SimpleStatusCell}" /> </igDP:Field.Settings> </igDP:UnboundField>
And this is my style:
<Style x:Key="Grid_SimpleStatusCell" TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <StackPanel Orientation="Horizontal"> <Image Source="/Shared/Images/EditStatus/Changed.png" VerticalAlignment="Center" HorizontalAlignment="Left" Width="16" Height="16" Margin="2,0,2,0" Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Record.DataItem.IsDirty, Converter={StaticResource Control_BoolToVisibilityConverter}}" /> </StackPanel> </ControlTemplate> </Setter.Value> </Setter> </Style>
The style sets the Visibility property of a status image using a converter along with the IsDirty property of the underlying data item. I used your snippet in the RecordUpdated event handler of the grid. At this moment, IsDirty has changed to true. However, the converter is not being invoked so I'm still stuck... Version, btw. is 7.2 RC
Hi Naveen
I see one problem with this approach though. Here is how I am using this.
if(e.Cell.Field.Name == "Fee")
{
DataRowView dv = e.Cell.Record.DataItem as DataRowView;
dv[
"Rate"] = Convert.ToDouble(e.Cell.Value) * .01;
e.Cell.Record.Visibility = Visibility.Collapsed;
e.Cell.DataPresenter.UpdateLayout();
e.Cell.Record.Visibility = Visibility.Visible;
}
After entering the value in the cell & hiting the Tab.. if the next column is a Editable it will not
go to edit mode & the horizontal scroll bar moves to the left.
Any idea how to solve these issues
Thanks
-Kiran
Thanks for your help. This worked for me
Hi, I was ably to solve the refresh records from using below code.
public static void RedrawRecord(Record record_) { if (record_ != null) { // Force Xam Grid to redraw the record so that all syles can be re-applied. record_.Visibility = Visibility.Collapsed; var presenter = DataRecordPresenter.FromRecord(record_); if (presenter != null) { presenter.UpdateLayout(); } record_.Visibility = Visibility.Visible; } }
Thanks,
Naveen
Hi
Is there any solution for refresh problem. Even i have the same problem. I bind DataView (DataTable) to grid & on editing one column I need to re-calculate the value of other 2 columns. I am doing this at the DataRow level. So changes are not reflecting unless I go click on the other columns.
Hi Can some one from infragistics comment on this? In addition to what I was doing earlier, I tried lot of options (below) but none causes the converter (which I am using to return color based on cell value) to be called. I was working with 9.1 builds. I am using latest sevice release 2010.2.20102.2045
var presenter = DataRecordPresenter.FromRecord(dataRecord);
var drCellArea = presenter.FindFirstChildByType<DataRecordCellArea>(); presenter.Visibility = Visibility.Collapsed; presenter.Visibility = Visibility.Visible; presenter.UpdateLayout(); presenter.InvalidateVisual(); drCellArea.Visibility = Visibility.Collapsed; drCellArea.Visibility = Visibility.Visible; drCellArea.UpdateLayout(); drCellArea.InvalidateVisual(); drCellArea.InvalidateProperty(Control.BackgroundProperty); _grid.Visibility = Visibility.Collapsed; _grid.Visibility = Visibility.Visible; _grid.UpdateLayout(); _grid.InvalidateVisual();