cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Unwanted Sorting of Listbox Options from Items in SharePoint Column

I am creating a Listbox in the canvas app linked to a SharePoint list column, and the items (rows) seem to be sorted, and I don't want that. I see nothing in edit mode in Properties or Advanced or other parts of the interface indicating why it is being sorted. I want the Listbox select options to read from top to bottom just as it displays in the SP list.

 

Background: I'm just getting started using Power Apps, having heavily made forms/pages using JavaScript/HTML/CSS inside & outside of SharePoint chrome for SP2010/2013/2016 on-premises using REST requests. I see there is no room for client-side scripting (JavaScript) in Power Apps so this will be entirely new for me. Becoming proficient in Power Apps is a required duty for me. If you know of one or more learning resources, I would appreciate link(s) to those resources.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

@StevePenner 

So, in this case, I would have a look at the View in SharePoint.  How is it sorting?  Because the default sort would be by ID in PowerApps.  If they don't match, then I am speculating that you have a Sort order set on the SharePoint list view.

Check that out first.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

6 REPLIES 6
Highlighted
Super User III
Super User III

@StevePenner 

Welcome to PowerApps!!  Leave your developer mind at the door...😂

 

Can you explain what you mean by a "SharePoint List Column" ?

 

In general, there is no sorting on items unless you specify it.  It will get and display items in the order received from the datasource.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
Highlighted

@RandyHayes 
I captured two images below. One is a SharePoint list (named "Configuration -- CAB Agenda") with only one column (named "Level 1 Header"). There are 9 items in the list, and effectively only 9 values in the column.

 

When the Listbox is created in the app (and I increased its size vertically), the 9 items appear, but now sorted in ascending fashion. You can see the settings of properties.

 

I have noted that one of the app's automatically created controls is a sort control at the top to toggle between ascending and descending sort, and so a Listbox object (are controls called "objects"?) likely has a property to indicate a sort, which is probably something I want disabled. I am not sure how to go about that.

 

And once I solve that simple problem, my next thing to figure out is how to add to the Listbox text for each option (item?) a preceding Arabic numerals as follows: "1. " & SP item string1, "2. " & SP item string2, etc.

 

I am guessing that is done by creating a collection or table (?) and then modifying each string in the collection or table and then using the modified strings in the collection in the Listbox. This is likely all basic beginner stuff to experienced power users.

 

 

SharePoint List with One ColumnSharePoint List with One ColumnApp Showing Listbox connected to SP List ColumnApp Showing Listbox connected to SP List Column

Highlighted

I have attached two images. One of the SharePoint List named "Configuration -- CAB Agenda" with one column named "Level 1 Header" and having 9 items of data type 'single line of text'. The other is of the app showing the ListBox connected to the column of items. The items in the ListBox are sorted in ascending order at time of connecting the control to the data.

 

This is not wanted. There is a Sort control made part of the app and so I am guessing that sorting of some control types (like text-style input controls) is automatic. I probably want to disable sorting for these control types and need to figure out how.

 

After solving the sort problem, I will then want to figure out how to precede an Arabic numeral before each text item in the ListBox, looping in a way that item 1 is "1. " & textItem1, "2. " & textItem2, etc. I am guessing that is done by creating a table or collection of the strings from the data source, when applying a function to prepend the text while running a loop, then connecting the modified collection or table to the ListBox. Or something like that.

 

SharePoint List With One Column of 9 ItemsSharePoint List With One Column of 9 ItemsListBox Control Connected to SharePoint List ColumnListBox Control Connected to SharePoint List Column

Highlighted

@StevePenner 

So, in this case, I would have a look at the View in SharePoint.  How is it sorting?  Because the default sort would be by ID in PowerApps.  If they don't match, then I am speculating that you have a Sort order set on the SharePoint list view.

Check that out first.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

Highlighted

@RandyHayes 
My SP list had been created new and each item created in that order. I added the SharePoint system-generated item ID to the view so it is clear that the SP sort is by ID value (image below)

 

I noticed in the Power Apps browser editor as well that when I put a cursor in the table created by the ListBox, the values of the fields in the table appear in a dropdown from the formula input control. In that dropdown of the table and its records and field, there was a column "ID" and its value exactly corresponded to the SP-generated ID values (also imaged below).

 

After some searching to understand sorting, the function SortByColumn() applied a sort to the ListBox items using the ID column and it worked (image below).

 

Now on to the next hurdle.

SP List adding system-generated ID to viewSP List adding system-generated ID to viewDisplay of table records and fields from formula barDisplay of table records and fields from formula barApplying SortByColumn() function to achieve wanted resultApplying SortByColumn() function to achieve wanted result

Highlighted

@StevePenner 

Odd...I've never seen PowerApps do anything by record by record sort (i.e. the order in which it was entered...usually the ID).

Glad you got things going now though.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (8,080)