Sorting remote data with DataManager

Hello,

I read a lot of thread and documentation about DataManager to load and sort (filtering etc) remote data to the grid component.

I create a CustomAdatptor, it works on load.
But when I want to send my sorting dto to my back end (in asp.net core 3.1), my dto is stilll empty. I tried to pass in the data attribut , in pvtData attribut but still nothing.

This is my code :

export class CustomAdaptor extends UrlAdaptor {

    public processQuery(dmDataManagerqueryQueryhierarchyFilters?: Object[]): Object {
        const original = super.processQuery.apply(thisarguments);

// My filtered dto
        let pagedFilteredPagedFilteredListDto = {};

        // sorting
        if (query.queries.length > 0) {
            query.queries.forEach((queryElementQueryOptions=> {
                pagedFiltered = {
                    sorting: {
                        orderType: queryElement.e.direction === 'Ascending' ? OrderTypes.Ascending : OrderTypes.Descending,
                        orderProperty: queryElement.e.fieldName,
                    },
                };
            });
        }

        const request = super.getQueryRequest(query);

        return {
            data: JSON.stringify(pagedFiltered),
            url: `${original.url}`,
            pvtData: original.pvtData,
            type: 'GET',
            contentType: 'application/json; charset=utf-8'
        };
    }


And this is my back end in ASP.NET Core 3.1 (I also tried with [FromRoute] )

[HttpGetMapToApiVersion("1")]
[ProducesResponseType(typeof(PagedListResultBase<Journal>), StatusCodes.Status200OK)]
public async Task<ActionResult<PagedListResultBase<Journal>>> Get([FromRoute]GetJournalsQuery query)

Best regards,
Charlotte

7 Replies

SK Sujith Kumar Rajkumar Syncfusion Team May 22, 2020 11:57 AM UTC

Hi Charlotte, 
 
Greetings from Syncfusion support. 
 
Currently the EJ2 Data Manager’s URL Adaptor supports only post request type and not GET request type. The GET request support is available with the Web API and OData Adaptor of the Data Manager. We have already logged feature request to “Provide GET request support for the URL adaptor” and it will be included in any of our upcoming releases. At the planning stage for every release cycle, we review all open features. We will let you know when this feature is implemented. 
 
You can track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through the following link.  
  
  
Please get back to us if you require any further assistance. 
 
Regards, 
Sujith R 



CR Charlotte ROZAN May 22, 2020 12:41 PM UTC

Hello Sujith Kumar Rajkumar,

can you tell me maybe how can I sort my grid with remote data (get http request), without loading all the data in init and let the client side make the sorting action ?


RR Rajapandi Ravi Syncfusion Team May 25, 2020 04:27 AM UTC

Hi Charlotte, 

Thanks for the update 

From validating your query we understand, you like to perform all grid actions such as paging, sorting, editing, grouping, filtering, etc on Client-side. To avoid post back for every action, set the grid to load all data on initialization and make the actions process in client-side. To enable this behavior, use the offline property of DataManager. Please refer the below documentation for more information. 


Regards,
Rajapandi R 



CR Charlotte ROZAN May 25, 2020 06:42 AM UTC

Sorry I was not clear. No I want to use http get queries to deals grid actions (paging/filtering/sorting/searching) on server side.
I found DataStateChangeEvent, can you tell me if this is the best solution yet ?

Thank you


SK Sujith Kumar Rajkumar Syncfusion Team May 26, 2020 06:46 AM UTC

Hi Charlotte, 

We suggest you to use the Web API adaptor to return HTTP GET request to the server for the Grid actions. More details on this adaptor can be found in the below help documentation link, 


We have prepared a local sample based on this for your reference. You can download it from the below link, 


Note: You can also use the dataStateChange event as you mentioned for this requirement. 


Let us know if you have any concerns. 

Regards, 
Sujith R 



CR Charlotte ROZAN May 26, 2020 08:26 AM UTC

Hello Sujith,

thank you for your sample with WebApiAdaptor. I prefer the DataStateChangeEvent solution because it's more asp.net core friendly (our backend are microservices so we can't have a strong link with frontend). 
When asp.net core 3.1 odata v4 will be stable, perhaps we will migrate to OdataV4Adaptator :)

Have a nice day and thanks again for your help


SK Sujith Kumar Rajkumar Syncfusion Team May 27, 2020 04:59 AM UTC

Hi Charlotte, 

We are happy to hear that your query has been resolved. Please get back to us if you require any further assistance. 

Regards, 
Sujith R 


Loader.
Up arrow icon