Hi, I have a xamdatagrid which saves column layout and filters. The layout is restored but the saved filters are ignored.
Field I want filtered
<igDP:Field Name="VolumeNumber" Label="Volume" Width="60" HorizontalContentAlignment="Center"> <igDP:Field.Settings> <igDP:FieldSettings> <igDP:FieldSettings.CellValuePresenterStyle> <Style TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Foreground" Value="{Binding Path=Cells[VolumeNumber].Value, Converter={StaticResource MyValueToColorConverter}}"> </Setter> </Style> </igDP:FieldSettings.CellValuePresenterStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field>
Preferences loading code
private void FillList() { StatusList = new RequestStatus(); RequestCollection = new VolumeRequestCollection(uc.FacilityGUID, null); string gridLayout = DataAccess.GetGridPreferences(uc.UserIDCode, uc.FacilityGUID, "requests"); if(!string.IsNullOrEmpty(gridLayout)) dgRequests.LoadCustomizations(gridLayout); }
Saved filter
<recordFilters> <RecordFilter FieldName="VolumeNumber"> <ConditionGroup LogicalOperator="And"> <ComparisonCondition Operator="NotEquals" Value="0" /> </ConditionGroup> </RecordFilter> </recordFilters>
Thanks
Peter
Thank you for your update.I am glad to hear your problem has solved!!
Best regards,Motoki
Thanks for the follow up. It was entirely my fault. Everything works fine. I was resetting the filters in an obscure place in the code. I'm sorry for wasting your time.
Hmm.. something seems to happen during save/load for DB but it is not sure.How about saving/loading the data as a static XML file to the server storage instead of DB?
I did what you suggested and in the method which saves the customizations i clear then load, like so.
private void SaveLayout() { string gridXML = dgPullGrid.SaveCustomizations(); DataAccess.SaveGridPreference(uc.UserIDCode, uc.FacilityGUID, _viewMode, gridXML); dgPullGrid.ClearCustomizations(CustomizationType.All); dgPullGrid.LoadCustomizations(gridXML); }
When this executes, there's no change to the grid. So, the filters and column position are retained or reloaded.
I have compared the XML in this method to the XML returned later when I read it back from the DB and load it and it's identical.
Hello Peter,Thanks for posting to the forum.
I am not sure what kind of data contains in the gridLayout.If the gridLayout is data created by the SaveCustomizations method, it should work.
What if you give the data created by the SaveCustomizations method to the LoadCustomizations method directly, does it works?I would like you to confirm that.
Sincerely,Motoki