对于来自用于同步网格的API的数据,分组并未进行分组

时间:2015-06-11 08:31:18

标签: angularjs syncfusion

我使用了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 };

这里是API方法,使用它我可以获取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"
            });
        }
    }

但拖动列

时不执行分组

如果我使用loacal数据,则执行分组,但不执行来自api的数据

1 个答案:

答案 0 :(得分:1)

以上问题解决了, 对于WebApi Adapter,将数据作为“Items”&amp; “计数”而不是结果和计数

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