Ticket S170233
Visible to All Users

Core - Support ListView sorting settings from the application model in Server Mode

created 12 years ago
Comments (2)
Dennis Garavsky (DevExpress) 12 years ago

    Currently, the XPObjectSpace class applies sorting for XPBaseCollection only, and ignores the XPServerCollectionSource:

    C#
    public virtual void SetCollectionSorting(Object collection, IList<SortProperty> sortProperties) { if(collection is XPBaseCollection) { ((XPBaseCollection)collection).Sorting = GetSortingCollection(sortProperties); } }

    This is because the the XPServerCollectionSource.DefaultSotring property uses a different format for sorting than the XPBaseCollection. It is however, possible to create a converter that will accept IList<SortProperty> and convert it into the required format. You can even do this yourself in your XPObjectSpace descendant by overriding the GetCollectionSorting/SetCollectionSorting methods.

    Dennis Garavsky (DevExpress) 12 years ago

      If you wish to implement this feature yourself, here is sample code from our EF classes to help get you started:

      C#
      public IList<SortProperty> GetSortProperties() { List<SortProperty> sortProperties = new List<SortProperty>(); String[] sortings = defaultSorting.Split(new String[] { ";" }, StringSplitOptions.RemoveEmptyEntries); foreach(String rawSorting in sortings) { String sorting = rawSorting.Trim(); String propertyName = ""; SortingDirection sortingDirection = SortingDirection.Ascending; if(sorting.ToLower().EndsWith(" desc")) { sortingDirection = SortingDirection.Descending; propertyName = sorting.Remove(sorting.Length - 5); } else { propertyName = sorting; } SortProperty sortProperty = null; if(propertyName.StartsWith("[")) { sortProperty = new SortProperty(propertyName, sortingDirection); } else { sortProperty = new SortProperty("[" + propertyName + "]", sortingDirection); } sortProperties.Add(sortProperty); } return sortProperties; } public void SetSortProperties(IList<SortProperty> sortProperties) { defaultSorting = ConvertSortPropertiesToString(sortProperties); entityServerModeFrontEnd.CatchUp(); } ... private String ConvertSortPropertiesToString(IList<SortProperty> sortProperties) { List<String> sortings = new List<String>(); if(sortProperties != null) { foreach(SortProperty sortProperty in sortProperties) { String sorting = sortProperty.PropertyName; if(sortProperty.Direction == SortingDirection.Descending) { sorting += " DESC"; } sortings.Add(sorting); } } return String.Join("; ", sortings.ToArray()); } ...

      Answers approved by DevExpress Support

      created 12 years ago (modified 12 years ago)

      We have implemented the functionality described in this ticket. It will be included in our next update(s).

      Please check back and leave a comment to this response to let us know whether or not this solution addresses your concerns.

        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.