Closed sebaiona closed 6 years ago
Hello @sebaiona. Thanks for finding this issue. I'll take a look at the code and try to add some tests and fix this issue.
Actually, the syntax should be:
odata/Employees?$expand=Boss($select=FirstName)&$select=EmployeeID
No you don't get the problem here...
I already have an expanded object in the datatable and I want to sort on a field of the sub-object.
See this example with Northwind service :
In the datatable I would put in a column the field Customer.CompanyName
and then I would want to sort data on it.
In this case the applyLazyLoadEvent
sorts on the field Customer.CompanyName
which is logical because it's the field of the column in the datatable.
The problem is that it generates this url :
http://services.odata.org/V3/Northwind/Northwind.svc/Orders?$top=10&$expand=Customer&$orderby=Customer.CompanyName
And the correct one would be :
http://services.odata.org/V3/Northwind/Northwind.svc/Orders?$top=10&$expand=Customer&$orderby=Customer/CompanyName
For orderby and filter you need indeed Customer/CompanyName
.
But for selecting, you need $expand=Boss($select=FirstName)
. I tried $select=EmployeeID, Boss.FirstName
or $select=EmployeeID, Boss/FirstName
and that does not work.
Yes perhaps but the only thing I was reporting is the orderby and filter cases with applyLazyLoadEvent
.
I don't have any other problem except these ones.
As it is, the function does $orderby=Customer.CompanyName
and it throws an error.
OK. I'll have to fix all code, or do you need an urgent fix?
I put a quick workaround in my code so it's not urgent, don't worry.
It should be fixed in https://www.npmjs.com/package/angular-odata-es5, just use latest version and this should work.
I updated the package, commented my workaround and... everything seems to work fine now !
Thanks !
thanks
Hello @StefH,
I found an issue with nested object property and OrderBy on ODataQuery. Indeed, when a column is mapped with a field which is a nested object field the orderBy won't work.
For example if we do a sort on this column :
<p-column [sortable]="true" field="status.label" header="Status"></p-column>
Then the
applyLazyLoadEvent
function will transform the query to execute something like :....../api/objects?$orderby=status.label asc
The problem is the good syntax would be :
....../api/objects?$orderby=status/label asc
Is it just possible to update the function to do a replace of "." by "/" on fields ?
PS : I didn't test it, but the same problem would happen with filters.
Thanks!!