Current filter:
                                You should refresh the page.
                                  • Hi, I have a problem with AspxGridLookupPropertyEditor, in a "TbAgenciaAduanal" Class I have a listing of "TbAduana" class called "Aduanas".
                                    The code snippet below is from a third class where I have a "AgenciaAduanal" field related to the TbAgenciaAduanal table and another "Aduana" field related to the TbAduana, of which I do not want to show all values but those that belong to the List of "Aduanas" related to the AgenciaAduanal selected. Normally we filter this with a DataSourceProperty which effectively filters the values, the problem is that when selecting the Customs Agency I do not see the values when deploying Aduanas, but I need to click on one of the columns to show me the possible values to select Because they don't appear immediatly. Please check the attached image. Thank you so much.

                                    [C#]
                                    [ModelDefault("LookupEditorMode", "AllItems")] [ModelDefault("PropertyEditorType", "DevExpress.ExpressApp.Web.Editors.ASPx.ASPxGridLookupPropertyEditor")] [Required] [RuleRequiredField] [DataSourceProperty("AgenciaAduanal.Aduanas")] public virtual TbAduana Aduana { get; set; } private TbAgenciaAduanal _AgenciaAduanal; [ModelDefault("LookupEditorMode", "AllItems")] [ModelDefault("PropertyEditorType", "DevExpress.ExpressApp.Web.Editors.ASPx.ASPxGridLookupPropertyEditor")] [ImmediatePostData] [Required] [RuleRequiredField] [VisibleInListView(false), VisibleInDetailView(false)] public virtual TbAgenciaAduanal AgenciaAduanal { get { return _AgenciaAduanal; } set { if (_AgenciaAduanal != value) { _AgenciaAduanal = value; if (objectSpace != null && objectSpace.IsModified && objectSpace.ModifiedObjects.Count != 0) objectSpace.SetModified(this, XafTypesInfo.Instance.FindTypeInfo(this.GetType()).FindMember(nameof(_AgenciaAduanal))); } } }

                                1 Solution

                                Creation Date Importance Sort by

                                Hello Freddys,

                                When a Data Source Property is updated, it is necessary to refresh the ASPxGridLookupEditor to reflect these changes immediately. Please see how to do this at Refresh the ASPxGridLookupPropertyEditor's Data Source (use the lookup.GridListEditor.Refresh method in v18.1).
                                This example is based on the IObjectSpace.ObjectChanged event. Ensure that your class raises INotifyPropertyChanged.PropertyChanged events correctly, as shown in the PropertyChanged Event in Business Classes topic.
                                Also, note that your AgenciaAduanal setter calls the IObjectSpace.SetModified method for the _AgenciaAduanal member. I am not sure what this code is intended for, but it looks like it should use the AgenciaAduanal name.

                                Show all comments
                                • Freddys Izquierdo 01.15.2020

                                  Hello
                                  Hi, I forgot to mention that it is a project in Entity Framework.
                                  "This example is based on the IObjectSpace.ObjectChanged event. Ensure that your class raises INotifyPropertyChanged.PropertyChanged events correctly, as shown in the PropertyChanged Event in Business Classes topic."
                                  The class already implements the interface: INotifyPropertyChanged and as you suggest I add the call to:

                                  [C#]
                                  OnPropertyChanged(nameof(AgenciaAduanal));

                                  But the result was the same.

                                  "Also, note that your AgenciaAduanal setter calls the IObjectSpace.SetModified method for the _AgenciaAduanal member. I am not sure what this code is intended for, but it looks like it should use the AgenciaAduanal name."
                                  Similarly, I changed _AgenciaAduanal to AgenciaAduanal in the SetModify and still not showing the expected result.

                                  [C#]
                                  objectSpace.SetModified(this, XafTypesInfo.Instance.FindTypeInfo(this.GetType()).FindMember(nameof(AgenciaAduanal)));

                                  The reason I use the above line is to refresh immediatly the view when the property AgenciaAduanal is modified, otherwise i had a delay.

                                  Just to Clarify that if instead of using the ASPxGridLookupPropertyEditor, I use the default dropdown everything works as expected.
                                  What else can I do?
                                  Thank you very much

                                • Anatol (DevExpress Support) 01.15.2020

                                  Please let me clarify whether or not you tried the controller provided in the Refresh the ASPxGridLookupPropertyEditor's Data Source section of the Reference (Foreign Key, Complex Type) Properties article in your application. Make sure to change its Contact and Department values according to your class and property names. To ensure that it runs correctly, add a breakpoint to the lookup.RefreshDataSource() line.

                                • Freddys Izquierdo 01.15.2020

                                  Yes I did add the controller bellow and set a breakpoint and in fact when i chance the value of AgenciaAduanal the lookup for Aduana is Refreshed but no result is displayed. When I click in any colum of the ASPcGrid it display the values.

                                  [C#]
                                  public class RefreshDataSourceTbAduanaController: ObjectViewController<DetailView, TbOperacion> { protected override void OnActivated() { base.OnActivated(); View.ObjectSpace.ObjectChanged += ObjectSpace_ObjectChanged; } private void ObjectSpace_ObjectChanged(object sender, ObjectChangedEventArgs e) { if (e.PropertyName != "AgenciaAduanal") return; ASPxGridLookupPropertyEditor lookup = View.FindItem("Aduana") as ASPxGridLookupPropertyEditor; if (lookup != null) { lookup.RefreshDataSource(); } } protected override void OnDeactivated() { View.ObjectSpace.ObjectChanged -= ObjectSpace_ObjectChanged; base.OnDeactivated(); } }
                                • Uriah (DevExpress Support) 01.16.2020

                                  Hello Freddys,

                                  We need to reproduce this behavior in a simple project to research it. Can you create such a project using your EF classes and ViewControllers?

                                • Freddys Izquierdo 01.21.2020

                                  Hello, sorry for the delay, here is the example with the same classes, please to reproduce the error you must first create several "Aduanas" with all the fields, then a create the "Agencia Aduanal" and associate some of the previously created "Aduanas". Finally go to the Home Sub Menu and create an "Operacion", select here the "Agenia Aduanal" and see that "Aduana" are not automatically refreshed as it should. Thank you very much

                                • Gosha (DevExpress Support) 01.22.2020

                                  Thank you for your project, Freddys! I see it uses version 18.1.12. The RefreshDataSource method works starting with version 18.2.7. In version 18.1, use the following code instead.

                                  [C#]
                                  lookup.GridListEditor.Refresh();
                                • Freddys Izquierdo 01.22.2020

                                  Yes, actually changing that line works as needed.
                                  Thank you very much

                                • Freddys Izquierdo 01.24.2020

                                  Hello, It Actually works for the basic scenario, which is selecting and TbAgenciaAduanal Object and populate the Aduana ASPxGridLookup, but if I clear the TbAgenciaAduanal ASPxGridLookup with the x button or change to another option it won't refresh the Aduana ASPxGridLookup. Any idea why?
                                  Thanks. 

                                • Arkady (DevExpress) 01.27.2020

                                  Hello,

                                  Your scenario looks the same as described in the How to update a source of ASPxGridLookupPropertyEditor ticket. Try to update the data source using the CollectionSourceBase.ResetCollection method as shown in that thread.

                                • Freddys Izquierdo 01.27.2020

                                  Hello, thanks, I let both lines, and all works fine now.

                                  [C#]
                                  private void ObjectSpace_ObjectChanged(object sender, ObjectChangedEventArgs e) { if (e.PropertyName != "AgenciaAduanal") return; ASPxGridLookupPropertyEditor lookup = View.FindItem("Aduana") as ASPxGridLookupPropertyEditor; if (lookup != null) { lookup.CollectionSource.ResetCollection(); lookup.GridListEditor.Refresh(); } }