0

我已经成功地将我的数据源的数据服务器端分组为移动列表视图,但是,我无法将其显示到屏幕上。data 中的_pristine数据正确显示了我的数据,结构如下:

results: Array[12] // 12 groups total
             0 = Array[5] // first group
                 0 = Object // groupID lives here
total: 14

这是我的数据源定义的相关部分:

schema: {
    groups: "[d.results]", // tried function(response) {return [response.d.results];}
    data: "d.results",
    total: "d.total",
},
serverGrouping: true,
group: "groupID",
.
.
.

我的数据源适用于客户端分组..

4

1 回答 1

0

当我这样使用它时,我得到了正确的,

        serverFiltering: true,
        serverGrouping: true,
        serverSorting: true,
        serverPaging: true,
        page: 1,
        pageSize: 10,
        schema: {
            data: "results",
            groups: "groups",
            total: "total",
            model: {
                id: "id"
            }
        }

在服务器端,

    // $group_by is the string, which is processed from the $_GET['group']
    // $results are the results grouped by

    $groups = array();

    if (!empty($group_by)) {
        foreach ($results as $result) {                
            $group_result = function_to_get_results_of_one_group($result['some_field']);                
            $groups[] = array(
                'field' => "The name of the field we want to display in the group by",
                'value' => "The value of the field we want to display in the group by",
                'items' => $group_result,
                'hasSubgroups' => FALSE,
                'aggregates' => array()
            );
        }
    }

    echo json_encode(
            array(
                'results' => $results,
                'groups' => $groups,
                'total' => $countPdct
            )
    );
    exit;

我不确定这是否是在服务器端获取记录的最有效方式。如果有人有更好的想法以更有效的方式获取记录,请提出建议。

希望这对在 kendo 数据源中寻找 Servergrouping 的人有所帮助。

于 2013-05-07T04:26:04.223 回答