Custom Datasource API - Custom Sorting not retained when switching between layouts

Answered
Henry asked on June 24, 2021

Hello,

For context, we are using the sortingMethod api to define a custom sort order for one of our fields and our datasource is set to the Custom Datasource API. We had some questions regarding the sort order:

  1. When we switch the layout from Compact form to Flat form, the sort order is not retained in the Flat layout, is this the expected behavior? If so, is there a way we can retain the custom sort order when switching from Compact to Flat?
  2. When we switch back from Flat to Compact, the sort order is not retained. However, we noticed that if we do switch back when the datasource is csv, for example, the sort order is retained. Is this the expected behavior?

We have provided jsFiddles for convenience. As a prerequisite, to reproducing the above our observed behaviors, please click the "Custom Sorting" button prior to switching layouts.

  1. jsFiddle (API Datasource)
  2. jsFiddle (CSV Datasource)

 
Please let us know if you need any additional information or if there is something wrong with the jsFiddles!
 
Kind regards,
Henry

8 answers

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster June 25, 2021

Hello, Henry,
 
Thank you for reporting the issue and for preparing examples.
 
Please note that sorting (ascending or descending) should also be defined for the flat form to be applied right after the form change. It is achievable using the flatSort property of the Slice Object.
We modified your JSFiddle for the demonstration: https://jsfiddle.net/flexmonster/hynv7Lcu/.
 
However, the sortingMethod seems to be erased after changing the form when using the custom data source API. This issue will be fixed in a minor update ETA on July 12. We will notify you when the version with a fix is available to download.
 
Feel free to reach out if any additional questions occur.
 
Best regards,
Illia

Public
Henry June 28, 2021

Hello, Illa,
 
Thank you for pointing us to the flatSort property! We noticed that if we have custom sorts on multiple fields, then if we change the ordering of the fields prior to changing the layout to the flat form, the custom sort order is lost when we change to the flat form. Is this the expected behavior? We've prepared a jsFiddle with custom sorting logic on the Category and Color fields for convenience. To reproduce,

  1. Click on the "Custom Sorting" button to sort the fields
  2. Open the fields popup and reorder the rows such that Color is before Category
  3. Switch the layout to flat form
  4. Note that the fields are no longer sorted according to their respective orders.
    • Yet when we switch back to the compact form, the sort order is restored.
    • Similarly, if we do not reorder the rows and instead go directly to the flat form after clicking the "Custom Sorting" button, the sort order is retained.

 
Kind regards,
Henry

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster June 30, 2021

Hello, Henry,
 
Thank you for reporting this issue.
 
It seems to be reproducible without any custom sorting applied. Also, we noticed it only appears when reordering fields in the Field List. As a temporary workaround, we suggest reordering fields by dragging them directly on the grid.
 
The issue will be fixed along with another problem mentioned in this thread ETA July 12.
 
Feel free to contact us if other questions arise.
 
Best regards,
Illia

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster July 13, 2021


Hello, Henry,
 
We are glad to inform you that issues with clearing flatSort when changing the slice and with sortingMethod when working with custom data source API were fixed.
 
This is included in the 2.9.3 version of Flexmonster: https://www.flexmonster.com/release-notes/.
 
You are welcome to update the component.
Here is our updating to the latest version guide for assistance: https://www.flexmonster.com/doc/updating-to-the-latest-version/.
 
Please contact us in case any questions arise.
 
Best regards,
Illia

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster July 21, 2021

Hello, Henry,
 
We are reaching out to ask if the recent fix works for you.
 
Looking forward to your feedback.
 
Kind regards,
Illia

Public
Henry July 21, 2021

Hello, Illia,
 
Whoops, sorry about that. I've been meaning to respond with a follow up. Yes, upgrading to 2.9.3 looks to have fixed the order retention.
Although, we did notice that for the Custom Datasource API, the aggregations at the root of the fields response now has precedence over the aggregations defined in the individual fields. For example, if the root aggregations has sum, but a field has an empty aggregation, sum appears as a valid aggregation option for the field in the fields list. Is this the expected behavior? Please let us know if it would be best to make another post/question on the forum.
 
Kind regards,
Henry

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster July 21, 2021


Hello, Henry,
 
Thank you for your feedback.
 
Concerning aggregations, if we understand correctly, root aggregations in your case means aggregations available for any, number, string, or date data types. In its turn, individual field aggregations imply aggregations defined for some specific hierarchies of your data source.
If so, we did not manage to reproduce the described behavior. Individual field aggregations have a higher priority than root ones.
Here is a JSFiddle for demonstration: https://jsfiddle.net/flexmonster/9dLcf583/.
It uses a sample predefined response where the "Price" field only has count aggregation available. In its turn, other numeric fields have all default aggregations. As a result, only count aggregation is available for the "Price" field.
 
Please note that array of aggregations should not be empty. Otherwise, all the root ones will be activated.
 
If we did not understand you correctly, please modify the example mentioned earlier to demonstrate the issue.
 
Also, it would help us if you could create separate forum thread for different questions.
 
Looking forward to hearing from you.
 
Kind regards,
Illia

Public
Henry July 21, 2021

Hello, Illya,
 
We've created a separate thread as a follow up.
 
Kind regards,
Henry

Please login or Register to Submit Answer