Hi ,
In below code default sorting is not working on UI interface.
a!gridTextColumn( label: "Served By", field: "servedBy", data: a!applyComponents( function: rule!getUserName(_), array: ri!subset.data.servedBy ) )
In this we are setting local.paginInfo in load and passing same on ein with() to this dataset subset. Then further this dataset i am passing to another rule where i am keeping grid section.
After clicking on header column sorting should be work but its not working. Tried lot but not found feasible solution.
Discussion posts and replies are publicly visible
totalCount: ri!subset.totalCount,value: local!gridSelection
All these possible solutions also applied. Add this in grid also.
If you're using an RI! value to pass in the data, then I'd assume the field needs to explicitly point to that location where the data actually resides. Try changing the field value to "data.servedBy" ?
i didn't get you. I am already pointing to that location only. Kindly elaborate bit more.
Hi
Rather than
field: "servedBy",
try
field: "data.servedBy"
you may need to also share what the rule!getUserName(_) is trying to achieve. I personally prefer to use the a!forEach() if that is an option to you, rather than applyComponents
Tried this option but not working. I was using forEach only but that was not working so i tried this one. I am stuck on this alot.
Ok - lets try some basic stuff to see where the problem might lie.
change your data line so that it just uses a standard display using index
data: index(ri!subset.data, "servedBy", "Data Not Found")
If the information displays correctly and sorts correctly on this combination then it would suggest an issue in your rule!getUserName.
If data doesn't show (you get the Data Not Found message) , then are you sure the input RI is being passed a datasubset ?
Show what values you are passing into via the test inputs - that might help also.
I sincerely hope you're not at a high enough version to support a!forEach and still using applyComponents. A mighty strong kudos goes out to you for learning to use it, as I have learned it as well and fully understand how nigh impossible that is. The problem is that the documentation is now so sparse that you're pretty much on your own if you ever have a bug in the applyComponents. Also, a!forEach is faster, easier, literally faster as in it processes in fewer miliseconds, and more powerful, and more robust. You can configure it to not crash and explode when it sees a null value. a!forEach would be a great addition to this code.
As to your current problem, I think your main difficulty is that your data is not in the form of a datasubset type. You applyComponents a rule over the data of a datasubset, and it returns a bunch of data, but that data is not in the form of a subset itself. What the datasubset provides you is a container that keeps both the data and the paging info in one place. You've got paging info attached to your servedBy, whatever that is, but that's not what you're using for your grid. Paging info is kind of worthless there. If you were to attach the same to the output of your apply components, that should work. Then the grid's paging info is right there with the data you ARE using to populate your grid. When you change that paging info, you'll re-page the output of the applyComponents.
Also, you probably want to do all the definition up in the local variables. I wouldn't put super complex logic right there in the grid definition. I'd just refer to complex logic I'd already done down there.
with(
local!dataForGrid: todatasubset(
data: a!applyComponents(...your code...),
pagingInfo: ri!subset.pagingInfo
)
...several lines later
a!gridTextColumn(
label: "Served By", field: "servedBy",
data: local!dataForGrid,
Reading this reply (which i generally agree with) makes me realize that we can't even guess as to why sauravk's sorting isn't working without him posting more code (particularly, how the paginginfo and datasubset are defined in their local variables, and the saveIntos of the gridField).
Also just as a general reminder, Community has a really neat feature for posting code in its own preformatted box which saves formatting, etc... i'm hoping if Sauravk posts a more verbose copy of the code he can use this feature
Sure will share you full code.
Hi Mike/David, Kindly find below code which I am using. I have customized and cut which was not necessary to share. But all n around I am using this approach. In this wherever I am using forEach or applyComonent() on that sorting not working but on rest of them its working fine. I hope now you will able to provide exact solution of this problem. --------------------------------Interface---------------------------------------- load( local!gridData: rule!BUS_getGridDetails(), local!gridSelection: a!gridSelection( pagingInfo: a!pagingInfo(startIndex: 1,batchSize: 10) ), with( local!dataSet: todatasubset( local!gridData.data, local!gridSelection.pagingInfo ), a!formLayout( label: "", contents: { rule!LIQR_gridScreen(local!dataSet) } ) ) ) --------------------------------Rule-------------------------------Passing ri!dataSet a!gridField( label: "Details", totalCount: ri!dataSet.totalCount, selection: true(), identifiers: index( ri!dataSet.data, "id", {} ), columns: { a!gridTextColumn( label: "ID", field: "id", data: index( ri!dataSet.data, "id", {} ) ), a!gridTextColumn( label: "Type", field: "type", data: index( ri!dataSet.data, "type", {} ) ), a!gridTextColumn( label: "Requested By", field: "createdBy", data: a!applyComponents( function: rule!getUserName(_), array: ri!datasubset.data.createdBy ) ), a!gridTextColumn( label: "Address", field: "address", data:a!forEach(items:index( ri!dataSet.data, "address", {} ), expression: rule!BUS_getPinCode(fv!item)) ) label: "Risk Associate", field: "riskAssociate", data: a!forEach( items: index( ri!datasubset.data, "riskAssociate", {} ), expression: rule!getUserName( fv!item ) ) ) }, value: local!gridSelection, saveInto: { local!gridSelection, local!gridSelection.selected, count( local!gridSelection.selected ) > 1, a!save( local!gridSelection.selected, local!gridSelection.selected[count( local!gridSelection.selected )] ), {} ) }, if( count( local!gridSelection.selected ) > 1, "You may only select one record.", null ) } )