cancel
Showing results for 
Search instead for 
Did you mean: 

Add a drop-down for sorting

amritbhgt
8 - Cloud Apps
8 - Cloud Apps

Hi,

I want to add a drop down to sort the blox based on what we have selected in that.

Eg. i have chosen # Submission that blox should be sorted based on that and user can select any field from the drop down.

amritbhgt_0-1707843311383.png

 

1 ACCEPTED SOLUTION

rapidbisupport
11 - Data Pipeline
11 - Data Pipeline

Hi @amritbhgt ,

The code below assumes that the dropdown has an ID of selectVal, and has a value associated with the title that is the same as the index of the item you want to sort by on the BloX. e.g. if you want to sort by '# Submission', and the '# Submission' is the third item in total on the BloX, you would set the value in the dropdown to 2.

 

widget.on('processresult', (w, args) => {
  // this is the 'value' of the selected dropdown title.
  const index = Number($('#selectVal').val())
  args.result.sort((a, b) => { if (a[index].Value < b[index].Value) { return 1 } else { return -1 } })
})

 

When you click the sort button, you should do a widget.refresh() on the target BloX widget.

 

Let me know how you go?

View solution in original post

3 REPLIES 3

rapidbisupport
11 - Data Pipeline
11 - Data Pipeline

Hi @amritbhgt ,

The code below assumes that the dropdown has an ID of selectVal, and has a value associated with the title that is the same as the index of the item you want to sort by on the BloX. e.g. if you want to sort by '# Submission', and the '# Submission' is the third item in total on the BloX, you would set the value in the dropdown to 2.

 

widget.on('processresult', (w, args) => {
  // this is the 'value' of the selected dropdown title.
  const index = Number($('#selectVal').val())
  args.result.sort((a, b) => { if (a[index].Value < b[index].Value) { return 1 } else { return -1 } })
})

 

When you click the sort button, you should do a widget.refresh() on the target BloX widget.

 

Let me know how you go?

DRay
Community Team Leader
Community Team Leader

Hello @amritbhgt ,

Did the solution offered by @rapidbisupport work for you? If so, please click the 'Accept as Solution' button so that other users with the same questions can find the answer faster. If not, please let us know so that we can continue to help.

Thank you.

David Raynor (DRay)

DRay
Community Team Leader
Community Team Leader

Hello @amritbhgt,

Did the solution offered by @rapidbisupport work for you?

If so, please click the 'Accept as Solution' button so that other users with the same questions can find the answer faster. If not, please let us know so that we can continue to help.

Thank you.

David Raynor (DRay)