Datatables, Dropdowns, and Transitioning pages

We’ve been using Datatables to display results of queries on a database and these work quite well in Aurelia. A drop down list is used to select an item which fires off a query returning the values which are then rendered in the datatable on the current page. A button is on the page which navigates to another page (by clicking ‘Manage’) and that page has a back button which comes back and loads the current page again. State is maintained so the search/ordering data for the datatable and the selected value of dropdown are saved and restored but the drop down selected value does not accept the saved state value (CNC) and simply displays the default “Please Select” rather than the correct value “CNC” in this case. jQuery such as (’#OrnamentGroup’).val(‘CNC’) does not do the job. Is there a way to get this to work in Aurelia?


The html is as follows:

and some typescript showing how the data is saved and restored

1 Like

selectedOrnamentGroup needs to be set by accessing the array of groups and setting the value of it equal to the result of a find operation.

this.selectedOrnamentGroup = this.ornamentGroups.find(y=>y.id === this.selectedOrnamentGroupId)
1 Like

Thanks very much for your help brandonseydel. It now works perfectly!

2 Likes