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!
<Border BorderThickness="2" BorderBrush="{Binding Path=Value, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource conv}}">
{
//get the processed presenter
// DataRecord record = (DataRecord) value; // Cell cell = record.Cells[0]; // int fieldValue = (int) cell.Value;
// DataRecord record = (DataRecord) value;
// Cell cell = record.Cells[0];
// int fieldValue = (int) cell.Value;
int fieldValue = (int)value; //return red if the value is above 10 return fieldValue > 10 ? Brushes.Red : Brushes.Black;
int fieldValue = (int)value;
//return red if the value is above 10
return fieldValue > 10 ? Brushes.Red : Brushes.Black;
}
Hello Joe,
Uh oh, the problem is related to the issue in the other thread
-> This is an artificial sample. I want to explicitely refresh my record *because* I cannot bind to a property that announces it's change: If it did, I wouldn't have to refresh the record manually. I can think of tons of samples where this absolutely might be the case - is there no workaround for this?
I'm still fishing for that DataRecord.Refresh method, but I'll accept any hack, now matter how dirty it might be
Cheers,
Was a solution to this ever found? I have very similar issues where I cannot use Databinding with change announcements.
Thanks,
I used to have below to force the converter to be called, but this hack does not work anymore after I upgraded to 2010.2 version. Any help?
// Force Xam Grid to redraw the record so that background color converter can be called.dataRecord.Visibility = Visibility.Collapsed;dataRecord.Visibility = Visibility.Visible;
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();
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; } }
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.