Hi Everyone,
I have the requirement data is displayed to UI through grid and provided the facility to user to export data in excel using export CDT to excel smart service. But when user applies sorting on UI and click on export the downloaded excel is not in the same sorting. can anyone please suggest me how to achieve this?
Thanks,
Shubham
Discussion posts and replies are publicly visible
Hi Shubham, I'm assuming the grid display is a data subset of your CDT, essentially a sorted version of the CDT is being displayed but the actual CDT used in the export does not have this sorting applied. If this is not the case, please elaborate on your configuration.
todatasubset().data is a common way to sort a CDT - you would apply the same a!pagingInfo() used in your grid(except for batch size typically), to achieve the same sorting.
a!localVariables( local!gridPaging: a!pagingInfo(1,10,a!sortInfo("id",true)), local!data: { a!map(id: 3, data: 7), a!map(id: 1, data: 5), a!map(id: 2, data: 6) }, local!dataSorted: todatasubset( local!data, a!pagingInfo( local!gridPaging.startIndex, -1, local!gridPaging.sort ) ), local!dataSorted.data )
I have to note that the Export CDT to Excel service is deprecated, however, I do continue to use it in production as we do not have a suitable replacement for some situations yet. Otherwise, a!exportDataStoreEntityToExcel() works great when you can export from your data store. Except, it does not have sorting
Chris said:Except, it does not have sorting
I have no idea why this hasn't been fixed yet
As far as the OP's use case - I think we need a bit more info about how they're capturing their Data CDT to be passed into the CDT to Excel smart service. I assume they might be freshly querying it in the process model, in which case the real trick (IMHO) is to simply pass the current filtering/sorting data from the form, out into the process model, and re-use it upon running the query that pulls back the (presumably whole) data set into the process CDT.