How to sort the data in edit Data Grid inside UiPath Apps

Hi folks,

Need to know, on how we could Sort the data which is loading from a DataService and is being shown in Edit Data Grid.

I want the latest record which was created to be displayed first.
@Arvind_Kumar1 @Parth_Doshi : Do you guys have any idea on how to do this?

Thanks
Aditya

Hello @adiijaiin ,

Edit grid do not support Sort into Query builder however after generating your query you can modify the sort filter but remember once you modify it again you will not be able to use into Query builder.

Here is a screen shot ,

See highlighted screen, By default this sort based on sort column, how ever you can write a If else condition on this saying if sort column is nothing when pay load then sort by CreatedDate ( you can choose your field name) and if click then sort by sort column again into else condition.

Thanks,
Arvind

Hi @Arvind_Kumar1

Even After adding this it’s not sorting it on the latest records first, and column that I have used is a System built-in field called “UpdateTime”, here’s the screenshot for the same.

Are you sure you have correct column name?

UpdateTime is the built-in field name, in Data Service, same as CreatedBy is the name of System built-in field.

Hello @adiijaiin ,

I just looked at my end and its working.

Is this updatedDate a column that you created?

@adiijaiin ,

Its default column.

hi @Arvind_Kumar1

This is the default column Name that is there in my DataService.

which I have put in

Can you try with other custom column if this is working?

Hi @Arvind_Kumar1

Tried with other columns as well, didn’t work.

Replace your Sort function with the below. “UpdateTime” is the default column in Entity
New SortOption(){addSortOption(“UpdateTime”, Not(False))}

Hello @adiijaiin
I was wondering on the same problem and came across your topic. The exact soluction that @Arvind_Kumar1 didn´t work form me either, but he did gave the idea that eventually let me to the solution… I took what arvind showed and started writing diferent combinations of the expression and I finally got these results. check the cases below.

These are the expressions that worked



As you can see I have this grid that is showing the most recent records up top and you can verify it by looking the date and time in the first column

based on that I tried this other set of combinations and none of them worked




Result of all three

I cant say I understand the why, and that is part of the reason Im replying your topic, because I want to understand how I can leverage the expressions to be able to make more advance sortings in the future. So I guess my question is for @Arvind_Kumar1
What is the SortColumn property of the grid control?, what exactly does it contain? Because it looks like when I try to display the value on a show message events, nothing comes in the message, but as you can see on the image of the only expression that seems to work, the branch that is taking is the “else”.

Hopefully in further App updates the apps them will tackle this case and make it eassier to handle sorting, and other capabilities which I won´t talk on this opportunity.

Have you sorted out the reason? Are you able now to do the proper sorting based on the creation date?

Hello @hgaber105 Yes!
As I stated above in my replay I showed a screenshot which has the expression that worked for me for sorting the grid based on the CreateTime field.

1 Like

Launch the UiPath Apps Studio and open the project containing the Data Grid you want to sort.

Locate the Data Grid component within your app’s interface. You should be able to access it from the design canvas or the component tree.

Ensure that your Data Grid is connected to a data source, such as a database, Excel file, or any other source where the data is stored.

In the properties panel for the Data Grid component, look for options related to sorting. Depending on the capabilities of the Data Grid component you’re using, there may be built-in sorting options available.

If sorting options are available, you may need to enable sorting functionality for the Data Grid. This could involve toggling a setting or selecting a sorting mode (e.g., ascending or descending).

Define Sorting Criteria: Specify the criteria based on which the data should be sorted. This could involve selecting a specific column or field to sort by.

Test Sorting Functionality: Save your changes and test the sorting functionality within the UiPath Apps preview mode or by running the app in a testing environment. Verify that the data is sorted correctly according to your specified criteria.

Refine and Iterate: If necessary, refine your sorting configuration and repeat the testing process until you’re satisfied with the results.

Publish Changes: Once you’re happy with the sorting functionality, publish your changes to make them available in the live version of your UiPath App.

In case someone else comes across this as I did, in my testing the default value for SortColumn is “”. If you click to sort a column ascending, then descending, then click again to go back to the default order, SortColumn is then nothing. So, what worked for me on the sort option is

If(MainPage.EditGrid.SortColumn is nothing or MainPage.EditGrid.SortColumn = "","CreateTime",MainPage.EditGrid.SortColumn)