-
-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing $count/inlinecount support for OData provider #287
Comments
Oh I wasn't aware that OData provides total count in their query, I thought we always had to provide that ourselves in the .Net Controller. I wonder if the boolean flag is really necessary but at the same time, we could disable the pagination so I guess the flag could be useful there. I'll take a look at that later, I thought at first this might be a breaking change but after a quick look, I guess not since user can pass whatever variable name. Can you provide a quick sample of dataset returned after this query change? I don't have access to OData server anymore |
Yes. See the following V3/V4 odata services
|
Thanks, however if I run those queries you sent, it shows the count in a strange variable. Is {
"@odata.context":"https://services.odata.org/V4/Northwind/Northwind.svc/$metadata#Customers",
"@odata.count":91,
"value":[{"CustomerID":"ALFKI","CompanyName":"Alfreds Futterkiste","ContactName":"Maria Anders","ContactTitle":"Sales Representative","Address":"Obere Str. 57","City":"Berlin","Region":null,"PostalCode":"12209","Country":"Germany","Phone":"030-0074321","Fax":"030-0076545"},{"CustomerID":"ANATR","CompanyName":"Ana Trujillo Emparedados y helados","ContactName":"Ana Trujillo","ContactTitle":"Owner","Address":"Avda. de la Constituci\u00f3n 2222","City":"M\u00e9xico D.F.","Region":null,"PostalCode":"05021","Country":"Mexico","Phone":"(5) 555-4729","Fax":"(5) 555-3745"}]
} |
I got the same name as well.
It is the common name as defined by the spec. See
https://docs.oasis-open.org/odata/odata-json-format/v4.01/csprd05/odata-json-format-v4.01-csprd05.html#_Toc14363451
…On Sat, Sep 21, 2019, 22:44 Ghislain B. ***@***.***> wrote:
Thanks, however if I run those queries you sent, it shows the count in a
strange variable. Is ***@***.***" a generic name and you can change it
or is that the commonly used name and is what you get on your side as well?
I need to have an answer on this since this will influence the Pagination.
{
***@***.***":"https://services.odata.org/V4/Northwind/Northwind.svc/$metadata#Customers",
***@***.***":91,
"value":[{"CustomerID":"ALFKI","CompanyName":"Alfreds Futterkiste","ContactName":"Maria Anders","ContactTitle":"Sales Representative","Address":"Obere Str. 57","City":"Berlin","Region":null,"PostalCode":"12209","Country":"Germany","Phone":"030-0074321","Fax":"030-0076545"},{"CustomerID":"ANATR","CompanyName":"Ana Trujillo Emparedados y helados","ContactName":"Ana Trujillo","ContactTitle":"Owner","Address":"Avda. de la Constituci\u00f3n 2222","City":"M\u00e9xico D.F.","Region":null,"PostalCode":"05021","Country":"Mexico","Phone":"(5) 555-4729","Fax":"(5) 555-3745"}]
}
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#287?email_source=notifications&email_token=ADFMBEMXFYABMA36WGRUHJLQKYXOTA5CNFSM4IYVFQ4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7ITDKA#issuecomment-533803432>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADFMBEO3FQDQIDLTOKE7FOLQKYXOTANCNFSM4IYVFQ4A>
.
|
@whtan98 is it (I also saw that it's {
"@odata.count":91,
"value": [{"CustomerID":"ALFKI","CompanyName":"Alfreds Futterkiste","ContactName":"Maria Anders","ContactTitle":"Sales Representative","Address":"Obere Str. 57","City":"Berlin","Region":null,"PostalCode":"12209","Country":"Germany","Phone":"030-0074321","Fax":"030-0076545"},{"CustomerID":"ANATR","CompanyName":"Ana Trujillo Emparedados y helados","ContactName":"Ana Trujillo","ContactTitle":"Owner","Address":"Avda. de la Constituci\u00f3n 2222","City":"M\u00e9xico D.F.","Region":null,"PostalCode":"05021","Country":"Mexico","Phone":"(5) 555-4729","Fax":"(5) 555-3745"}]
} or {
"@odata.count":91,
"items": [{"CustomerID":"ALFKI","CompanyName":"Alfreds Futterkiste","ContactName":"Maria Anders","ContactTitle":"Sales Representative","Address":"Obere Str. 57","City":"Berlin","Region":null,"PostalCode":"12209","Country":"Germany","Phone":"030-0074321","Fax":"030-0076545"},{"CustomerID":"ANATR","CompanyName":"Ana Trujillo Emparedados y helados","ContactName":"Ana Trujillo","ContactTitle":"Owner","Address":"Avda. de la Constituci\u00f3n 2222","City":"M\u00e9xico D.F.","Region":null,"PostalCode":"05021","Country":"Mexico","Phone":"(5) 555-4729","Fax":"(5) 555-3745"}]
} or something different? I'd like to make sure that the Example Grid OData represent the correct behavior. I guess that |
I created the PR #291, if you could review it and answer the question in previous post before I merge the code. The PR has a few files because I also updated Jest unit tests and Cypress E2E tests (the Note that I changed your code a bit because if (this._odataOptions.enableCount === true) {
const countQuery = (this._odataOptions.version >= 4) ? '$count=true' : '$inlinecount=allpages';
queryTmpArray.push(countQuery);
} |
I got exactly the same observations as yours. However, looks like things may get tricky if the grid tries to consume the "count" control information, after reading the following excerpts from ODATAv4 spec https://docs.oasis-open.org/odata/odata-json-format/v4.01/csprd05/odata-json-format-v4.01-csprd05.html#_Toc14363451 |
From what you pointed out, that seems to mean that the result will be Can you validate that it works on your side. I'd like to release a new version this week. Thanks |
Agreed. The count control info should be handled separately. BTW, below are my findings for the default name:
As the odata service always specify the ODATA-Version in the RESPONSE HTTP header See attached curl output Will let you know once I tested the changes. Many thanks |
Oh I thought the text you sent for only for the Request Header but now I see it's for both Request & Response Headers. Anyhow, my lib won't explicitly change anything in the Request Header, the only thing my lib does is to build the OData query string, the user (you) do whatever you want to with the Request afterward (meaning you can choose to add the OData version in your Request if you wish but I assume most people won't because again my lib doesn't handle the http call itself). Also, I looked back at the OData Wiki and I realized that the callback, which has to change the pagination total count property, was not shown in the OData code Wiki so I updated the Wiki, basically the following getCustomerCallback(response) {
// totalItems property needs to be filled for pagination to work correctly
// however we need to force Angular to do a dirty check, doing a clone object will do just that
this.gridOptions.pagination.totalItems = response.totalRecordCount;
this.gridOptions = Object.assign({}, this.gridOptions);
this.dataset = response.items as Customer[];
} However the OData example always had that piece of code.. and again it's up to the user (you) to handle the total count returned from the callback and update the pagination count (else the pagination will be broken). |
It works correctly for me. Many thanks for the great effort |
@whtan98 Side note, I won't publish a new version this week, it's too late now and I found some small bugs in the Editors that I'd like to fix before releasing. So next week most probably |
I'm afraid I don't have any proper code for postProcess yet, as I still very much on exploring how to make use of Angular SlickGrid |
feat(odata): add "enableCount" flag to add to OData query, closes #287
Guess I'll wait to do that next enhancement then, I need someone with access to OData. Thanks |
Now released under version 2.11.0 |
Great work. Thank you !
…On Thu, Oct 3, 2019, 05:25 Ghislain B. ***@***.***> wrote:
Now released under version 2.11.0
<https://github.com/ghiscoding/Angular-Slickgrid/releases/tag/v2.11.0>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#287?email_source=notifications&email_token=ADFMBEPHO64P4RPTA42CKDLQMUGVFA5CNFSM4IYVFQ4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAGHQLQ#issuecomment-537688110>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADFMBENGVNBBL7LH367WJODQMUGVFANCNFSM4IYVFQ4A>
.
|
I'm submitting a Bug report
The currentOdataQueryBuilderService does not support the following option:
Your Environment
Context
OdataQueryBuilderService does not support "enableCount" option
Possible Solution
Suggest to add the following to OdataQueryBuilderService .buildQuery()
Code Sample
The text was updated successfully, but these errors were encountered: