pnp / List-Formatting

List Formatting Samples for use in SharePoint and Microsoft Lists
https://pnp.github.io/List-Formatting/
MIT License
1.75k stars 844 forks source link

FAQ Accordion overwrites sorting/ random order #770

Closed VictKat closed 7 months ago

VictKat commented 7 months ago

using the accordion code quite frequently and in the past with filtering into sections to reduce FAQ lists, in this instance I have been trying to sort the view based on additional columns, tested number and text columns for sorting. Once code is applied, a sorted view changes order completely. Any suggestions what could cause this? Even after re-entering values in order so they are already sorted by ID will still shuffle the questions to random order.

tecchan1107 commented 7 months ago

Hi @VictKat .

Is it possible to send us a screenshot of the FAQs actually being randomly ordered? Also, if possible, I would like a screenshot of the columns, sort and group by settings in the view so that I can see if I can reproduce it. image

VictKat commented 7 months ago

Hi, I have noticed the sorting is actually alphabetical by the question column instead of random, no matter if I select the ID column or number column added to try and force a specific order

accordion view issue

tecchan1107 commented 7 months ago

Thanks for the screenshot!

Yes, when grouping, the order of GROUP BY is applied first. So, if you want to sort the questions in order, you must set a number or alphabet at the beginning of the column values to be grouped. (e.g. 01.Whart is XXX, 02.How is YYY, 03.What is ZZZ)

Also, if you set the characters for sorting at the beginning and do not want them to appear, you can use a combination of the substring and indexOf operators to remove them.

Example: to remove the first 3 characters of a grouped column value, change @group.fieldData.displayValue to =substring(@group.fieldData.displayValue,3,indexOf(@group.fieldData.displayValue+'^','^')).

image

image