cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Is there a way to change the display order of the data options in a MemberFilterTile?

ewoytowitz
7 - Data Storage
7 - Data Storage

I am using the MemberFilterTile component from @sisense/sdk-ui. In some cases, I want the options I'm seeing to be displayed in a different order. Is there a way to change the order in which the options are displayed? For example, in this Competition Year filter I would want the most recent year displayed first, instead of last (DESC instead of ASC order).

ewoytowitz_0-1712245334948.png

 

1 ACCEPTED SOLUTION

IvanBiletskyi
Sisense Team Member
Sisense Team Member

Yes, you can. You need to sort an Attribute that you are using for this filter.

For example:

import { filterFactory, Sort } from '@sisense/sdk-data';
  
const sortedYearsAttribute = DM.Commerce.Date.Years.sort(Sort.Descending);
const filter = filterFactory.members(sortedYearsAttribute, ['2013-01-01T00:00:00']);
//...
return (
  <MemberFilterTile
    title={'Year'}
    attribute={sortedYearsAttribute}
    filter={filter}
  />
)

 

View solution in original post

4 REPLIES 4

ILLIA
Sisense Team Member
Sisense Team Member

Hello!

I am afraid it is not possible with current logic (neither available options nor selected options, both are sorted ASC by default not depending on passed members order), please feel free to submit your filter sorting control idea on Product Feedback forum:
https://community.sisense.com/t5/product-feedback-forum/idb-p/ideas/tab/most-recent

Best regards,

ILLIA

IvanBiletskyi
Sisense Team Member
Sisense Team Member

Yes, you can. You need to sort an Attribute that you are using for this filter.

For example:

import { filterFactory, Sort } from '@sisense/sdk-data';
  
const sortedYearsAttribute = DM.Commerce.Date.Years.sort(Sort.Descending);
const filter = filterFactory.members(sortedYearsAttribute, ['2013-01-01T00:00:00']);
//...
return (
  <MemberFilterTile
    title={'Year'}
    attribute={sortedYearsAttribute}
    filter={filter}
  />
)

 

Thank you Ivan! That worked perfectly. Is there also a way to do more complicated sorting (other than ascending and descending)? For example, I have another member tile filter where I am using a "Code Name" as the attribute, but I want the list of "Code Names" to be displayed in ascending order according to the associated "Code Id" (a different attribute in the same interface/dimension as "Code Name").

Unfortunately, custom sorting is not possible for now as it is applied by the backend (DB). We don't sort the array of filter members on the client side because we have lazy-loading of members, so data chunks should come to the client already sorted by the backend.

Perhaps, at some point, we will add the possibility of passing a raw members array to the filter-tile instead of loading them from the DB. This way, you will be able to query all the members you need and sort them as you want before passing them to filter-tile. However, currently, it is not possible.