We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Proper formatting needed for returning OData 4 aggregate count data to grid

Using ODATA 4, I am trying to get an aggregate count of visits for a collection of applications.  However, because SyncFusion appends, $Count, $Skip and $Top parameters to the end of my datasource, I am unable to format the query appropriately.

The original query works fine:
https://myDomain/applications/-1/sessions?$format=json&$apply=groupby((MyID),aggregate(MyID with count as Visits))

However, when I try to use it with the Grid, it does not work:

@(Html.EJ().Grid<object>("Grid")
     .AllowPaging()
        .AllowSorting()
        .Datasource(d => d.URL("https://myDomain/applications/-1/sessions?$format=json&$apply=groupby((MyID),aggregate(MyID with count as Visits))")         
        .Columns(col =>
            {
                col.Field("ApplicationID").HeaderText("Application ID").TextAlign(TextAlign.Right).Add();
                col.Field("Visits").HeaderText("Visits").TextAlign(TextAlign.Right).Add();

            })     

The query is then formatted by SyncFusion as: 
https://myDomain/applications/-1/sessions?$format=json&$apply=groupby((MyID),aggregate(MyID%20with%20count%20as%20Visits))/$count=true&$skip=0&$top=12
This obviously does not work because of the backslash.

I tried using the '.Query', but I have been unsuccessful in setting this up properly.  For example:
.Query("new ej.Query().apply(groupby((MyID),aggregate(MyID with count as Visits))))")
.Query("new ej.Query().select(apply=groupby((MyID),aggregate(MyID with count as Visits)))")


Can you give me the proper syntax for setting this up?  Also, since we work with large amounts of data, the aggregate has to be done via query as it would be unreasonable to download everything for these counts.

Thanks.

4 Replies

BM Balaji Marimuthu Syncfusion Team August 25, 2015 11:12 AM UTC

Hi Jim,

Thanks for using Syncfusion Products.

We have faced the mentioned issue “Backslash is added to the query formatted in Odata V4” in version 13.2.0.30. And it has been fixed in the latest version so if you are using our product version prior to v13.2.0.30, we suggest you to upgrade to our latest version to overcome the issue.

Syncfusion latest version can be downloaded from the following link: 
http://www.syncfusion.com/forums/119866/essential-studio-2015-volume-2-service-pack-release-v13-2-0-34-available-for-download


Please get back to us if you need any further assistance.

Regards,
Balaji Marimuthu



BM Balaji Marimuthu Syncfusion Team August 25, 2015 11:16 AM UTC

Hi Jim,


Please ignore our previous update.

We have faced the mentioned issue “Backslash is added to the query formatted in Odata V4” in version 13.1.0.30. And it has been fixed in the latest version so if you are using our product version prior to v13.1.0.30, we suggest you to upgrade to our latest version to overcome the issue.

Syncfusion latest version can be downloaded from the following link: 
http://www.syncfusion.com/forums/119866/essential-studio-2015-volume-2-service-pack-release-v13-2-0-34-available-for-download


Please get back to us if you need any further assistance.

Regards,
Balaji Marimuthu



JW Jim Woods August 26, 2015 04:53 AM UTC

Thanks for your help. 

Since, I originally added this functionality to my solution using Nuget, I uninstalled my previous version and installed the MVC 5 package that pertained to the latest version (released in August 2015).

Aggregates now seem to be working properly.


IR Isuriya Rajan Syncfusion Team August 27, 2015 08:22 AM UTC

Hi jim,
Thanks for your patience.
Please let us know if you require further assistance on this.

Regards,

Isuriya R      


Loader.
Live Chat Icon For mobile
Up arrow icon