Grid sorting problem

Hi All

When UrlAdaptor used in e-data-manager "Grid" not sorting by columns. If I chage it to datasource attribute and get data from a list (onGet method) it works. 

Any idea? 

I tried it with version 18.4.0.30 and latet 18.4.0.48 as well. 

This is my codes:

Data Api URL:

[Route("api/getUserData")]
        public IActionResult UrlDatasource([FromBody] DataManagerRequest dm)
        {
            IEnumerable DataSource = _unitofwork.User.GetAll();
            DataOperations operation = new DataOperations();
            int count = DataSource.Cast<ApplicationUser>().Count();

            if (dm.Skip != 0)
            {
                DataSource = operation.PerformSkip(DataSource, dm.Skip);   //Paging
            }
            if (dm.Take != 0)
            {
                DataSource = operation.PerformTake(DataSource, dm.Take);
            }
            return dm.RequiresCounts ? new JsonResult(new { result = DataSource, count = count }) : new JsonResult(DataSource);
        }


Grid Codes:

<ejs-grid id="Grid" allowResizing="true" allowFiltering="true" allowSorting="true" enableAutoFill="true"
              enableHover="true" rowHeight="22" allowPaging="true">
        <e-data-manager url="/api/getUserData" crudUrl="/api/usercrud" adaptor="UrlAdaptor" crossdomain="true"></e-data-manager>
        <e-grid-editSettings allowAdding="true" allowDeleting="false" allowEditing="true" mode="Dialog" showConfirmDialog="true" allowEditOnDblClick="true"/>
        <e-grid-filterSettings type="Excel"></e-grid-filterSettings>
        <e-grid-pagesettings pageCount="5"></e-grid-pagesettings>
        <e-grid-columns>
            <e-grid-column field="UserName" headerText="Kullanıcı Adı" textAlign="Right" allowEditing="false" width="200"></e-grid-column>
            <e-grid-column field="Adi" headerText="Ad" width="150"></e-grid-column>
            <e-grid-column field="Soyadi" headerText="Soyad" width="150"></e-grid-column>
            <e-grid-column field="Email" headerText="Email"></e-grid-column>
            <e-grid-column field="PhoneNumber" headerText="Telefon No"></e-grid-column>
            <e-grid-column field="KayitTarihi" headerText="Kayıt Tarihi" format="d.M.y" allowEditing="false" width="200"></e-grid-column>
            <e-grid-column field="IsActive" headerText="Aktiflik" displayAsCheckBox="true" editType="booleanedit" width="100"></e-grid-column>
        </e-grid-columns>
    </ejs-grid>



2 Replies 1 reply marked as answer

NO N Ozer Senol March 21, 2021 09:14 AM UTC

I changed e-data-manager as below and it worked! you need to add this trick on Syncfusion documentation!!!

<e-data-manager url="/api/getUserData" crudUrl="/api/usercrud" adaptor="UrlAdaptor" crossdomain="true offline="true" "></e-data-manager>


VS Vignesh Sivagnanam Syncfusion Team March 22, 2021 10:37 AM UTC

Hi Ozer  

Greetings from Syncfusion support 

Based on your query we suspect that you need to perform server side sorting in the grid with urladaptor. In this you also mentioned that you are able to resolve the issue by providing the datamanager’s offline property to the grid.  

On enabling this property the entire data will be fetched in the initial request itself and all the consecutive actions will be performed in the client-side itself(considering it as a local data). If you want to perform your operation in the server side, please remove the offline property which will then send request for each Grid action like, Filter, Sort, CRUD, etc. 

To perform sorting in the server side, we need to handle the sorting operation on the server side. Please refer the below Code example, sample and Documentation for your reference, 

public IActionResult UrlDataSource([FromBody]DataManagerRequest dm) 
        { 
            IEnumerable<OrdersDetails> DataSource = OrdersDetails.GetAllRecords().AsEnumerable(); 
            DataOperations operation = new DataOperations(); 
            if (dm.Sorted != null && dm.Sorted.Count > 0)               //Sorting 
            { 
                DataSource = operation.PerformSorting(DataSource, dm.Sorted); 
            } 
            int count = DataSource.Cast<OrdersDetails>().Count(); 
            if (dm.Skip != 0) 
            { 
                DataSource = operation.PerformSkip(DataSource, dm.Skip);   //Paging 
            } 
            if (dm.Take != 0) 
            { 
                DataSource = operation.PerformTake(DataSource, dm.Take); 
            } 
            return dm.RequiresCounts ? Json(new { result = DataSource, count = count }) : Json(DataSource); 
        } 



Regards 
Vignesh Sivagnanam 


Marked as answer
Loader.
Up arrow icon