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

Grouping is not perorming on data comes from API for syncfusion grid

I have used syncfusion grid::
         <div id="Grid" ej-grid e-datasource="data" e-query="query" e-columns="columns" e-toolbarsettings='tools' e-toolbarclick="toolbarHandler" e-pagesettings="pagesttings" e-allowpaging="true" e-allowsorting="true" e-actionbegin="actionBegin" e-allowgrouping="true" e-enabledropareaanimation="false" e-groupsettings="grouping"></div>


    var newColumns = [
                    { field: "Id", headerText: "ID", width: 75, textAlign: ej.TextAlign.Right },
                    { field: "Name", headerText: "Name ", width: 75, textAlign: ej.TextAlign.Right },
                    { field: "Type", headerText: "Type", width: 75, textAlign: ej.TextAlign.Right },
                    { field: "Kilogram", headerText: "Kilogram", width: 75, textAlign: ej.TextAlign.Right },
                    //{ field: "Category", headerText: "Category", width: 75, textAlign: ej.TextAlign.Right }
];

$scope.columns = newColumns;

$scope.data = ej.DataManager({ url: "http://localhost:49501/api/program/GetProgramFullListForSyncfusion", adaptor: "WebApiAdaptor" });
$scope.query = new ej.Query().addParams('selecedYear', '2014').addParams('accessId', '1');

$scope.pagesttings = { pageSize: 12, pageCount: 4 };


here is API method using which i have get data for grid::

public object GetProgramFullListForSyncfusion()
    {
        var queryString = HttpContext.Current.Request.QueryString;
        int skip = Convert.ToInt32(queryString["$skip"]);
        int take = Convert.ToInt32(queryString["$top"]);
        string accessId = queryString["accessId"];
        try
        {
            return new { result = ProgramService.GetFullListForSyncfusion(skip, take), count = ProgramService.GetActiveInactiveCount() };
        }
        catch (TimeoutException)
        {
            throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.RequestTimeout)
            {
                Content = new StringContent("An error occurred, please try again or contact the administrator."),
                ReasonPhrase = "Critical Exception"
            });
        }
        catch (Exception)
        {
            throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)
            {
                Content = new StringContent("An error occurred, please try again or contact the administrator."),
                ReasonPhrase = "Critical Exception"
            });
        }
    }


but grouping is not performed while drag the column

every time call goes to api while drag a column or performing grouping

if i use local data then grouping is performed but not for data from api



1 Reply

AS Alan Sangeeth S Syncfusion Team June 12, 2015 12:36 PM UTC

Hi Gomtesh,

Thanks for using Syncfusion products.

We have analyzed your code snippets and found that you have returned data wrongly as “result“ & “count” which is cause of the issue.

For WebApi Adaptor, we need to return data as “Items” & “Count”. Please refer the following code snippets.

public object Get()

        {


return new { Items = data.Skip(skip).Take(take), Count = data.Count() };


        }




For your convenience we have created a sample and the same can be downloaded from below link.

Sample: http://www.syncfusion.com/downloads/support/forum/119370/ze/EJGrid_(2)246376107

Please let us know if you need any further assistance.
Regards,
Alan Sangeeth S

Loader.
Up arrow icon