Ticket Q433342
Visible to All Users

Core - Make it possible to specify a dynamic criteria for lookups in code of business objects (similar to DataSourcePropertyAttribute)

created 12 years ago

Hi,
according to the How to use server mode with "How to: Filter Lookup List Views - Scenario 4 - Custom Lookup Property Data Source" and the Performance - Support fast operation with large amount of data in a nested and lookup List View (turn on server mode) tickets I have a further question. Could you explain howto use servermode when using a the DataSourceProperty attribute. I wasn't able to manage it, neither with a XPCollection<T> nor a XPServerCollectionSource. Am I right that it should work, because the ticket is a duplicate of an implemented one?
Thanks.
Kim

UPDATE:
As an example see your documentaion How to: Filter Lookup List Views "Scenario 4 - Custom Lookup Property Data Source". I want to have the Order.Accessory Lookup to run in servermode. It's just the same as Franco Bonacchi ask.

Comments (3)
Aleksei M. (DevExpress) 12 years ago

    Hello Kim,
    Thank you for contacting us.
    I am afraid that this issue is unclear to me. Would you please send us a sample project where you are trying to implement your task and describe your scenario in greater detail?

      I have updated my original post.

      Aleksei M. (DevExpress) 12 years ago

        Hello Kim,
        Thank you for the additional information. I hope I have entirely understood your scenario now and will publish an answer for you soon.

        Answers

        created 12 years ago (modified 5 years ago)

        Hello Kim,
        We have implemented a new DataSourceCriteriaPropertyAttribute attribute in 12.2. You can apply it to collection and reference properties (of course, you can also set it for the class member, ListView column or DetailView item in the application model) to filter them, similar to other standard DataSourceProperty and DataSourceCriteria attributes that work in this scenario.
        The only difference is that the constructor of this attribute accepts a string name of the property of the CriteriaOperator type. This capability allows you to *dynamically* perform custom filtering of almost any complexity, and that works in the server mode (which is not always possible when DataSourcePropertyAttribute is used).

        Example #1

        C#
        private YourBusinessObject _YourLookupProperty; //[DataSourceCriteria("Demo = 'Test'")] [DataSourceCriteriaProperty(nameof(DemoCriteria))] public YourBusinessObject YourLookupProperty { { get => _YourLookupProperty; set => SetPropertyValue(nameof(YourLookupProperty), ref _YourLookupProperty, value); } [Browsable(false)] public CriteriaOperator DemoCriteria { get { return CriteriaOperator.Parse("Demo = 'Test'"); } }

        Example #2

        C#
        private YourBusinessObject _YourLookupProperty; [DataSourceCriteriaProperty(nameof(Filter))] public YourBusinessObject YourLookupProperty { get => _YourLookupProperty; set => SetPropertyValue(nameof(YourLookupProperty), ref _YourLookupProperty, value); } [Browsable(false)] public CriteriaOperator Filter { get { return new InOperator("FirstName", SomeListProperty); } }
          Comments (1)
          created 12 years ago (modified 12 years ago)

          Hello Kim,
          The UseServerMode option and the DataSourceProperty attribute do not work simultaneously.
          An independent ServerCollection is created as a data source for a lookup ListView when the UseServerMode option is set for that ListView model.
          However, when the DataSourceProperty attribute is applied for the lookup property, the property pointed in the attribute is used as a lookup data source, and the standalone independent ServerCollection is not created and is not used at all.
          So, when the UseServerMode option and the DataSourceProperty attribute are used simultaneously, the DataSourceProperty attribute wins.
          Please let me know if I can assist you further.

            Show previous comments (8)
            Dennis Garavsky (DevExpress) 12 years ago

              Hello Kim and Franco,
              Your suggestions make sense, and it is something we can work on in the future. I cannot promise any ETA, though. Thank you for your great input in this regard.
              In the meantime, I believe that you will be able to accomplish your task by using a ViewController (set the CollectionSource's Criteria property as you require). Does it meet your needs?

                Hi Dennis,
                Yes, a dynamic criteria would be fine. Your right, I already thought about implementing a controller, and I think I will be able to do so ;).
                Thanks!

                Dennis Garavsky (DevExpress) 12 years ago

                  Thank you for the feedback, Kim!

                  Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

                  Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.