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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

119370 Jun 11,2015 11:59 AM UTC Jun 12,2015 12:36 PM UTC JavaScript 1
loading
Tags: ejGrid
Gomtesh
Asked On June 11, 2015 11:59 AM UTC

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



Alan Sangeeth S [Syncfusion]
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;