kendo grid refresh后改变排序与过滤,如何获取参数?

新手上路,请多包涵

1.问题描述:

我的项目是kendo和angular相结合的,用到了jquery kendo的angular扩展。初始化kendo grid table时,并没有设置datasource,然后通过setDataSource和refresh方法刷新数据,然后过滤和排序,都能正常使用,我怎么获取过滤和排序的参数,用于其他ajax使用。

$scope.mainGridOptions.dataSource._filter $scope.mainGridOptions.dataSource.filter() 两个方法都无法获取到过滤参数;
为什么点击cloumnMenu的排序过滤,kendo可以自动发请求,带有过滤排序条件,他是怎么获得的参数?

2.相关代码:

//初始化kengoGrid without datasource
$scope.mainGridOptions = {
    toolbar:[
    {
        template: "<button excel-export-btn kendo-grid-element='mainGridOptions' data = 'paramData()' down-url='kendoExcelUrl' class='k-button k-button-icontext'><span class='k-icon k-i-excel'></span>export</button>"
    ],
    sortable: true,
    resizable: true,
    pageable: _kendoConfigure.pageable,
    filterable:_kendoConfigure.filterable,
    noRecords: true,
    columnMenu: true,
    messages: _kendoConfigure.messages,
    columnMenuInit: _kendoConfigure.columnMenuInit,
    columns: columnConfig($rootScope.userData.role)
};
// 获取定制化数据,刷新kendoGrid的数据
function initGrid(begin,end,dateType,inviteCodeType,url){
    var dataSource = dataSourceInit(
        url,
        {
            'start_date':_dateToString(begin),
            'end_date':_dateToString(end),
            'type':dateType,
            'code_type':inviteCodeType,
            'enterprise_status':$scope.enterprise_status,
            'assign_status':$scope.assign_status
        }
    );
 $("#mainGridOptions").data("kendoGrid").setDataSource(dataSource);
 $("#mainGridOptions").data("kendoGrid").refresh();
}
//利用kendo的方法请求后台数据
function dataSourceInit(url,data){
    var dataSource = new kendo.data.DataSource({
        transport: {
            read: {
                url:url,
                type:$rootScope.kendoHttpType,
                dataType: 'json',
                data:data
            }
        },
        schema : {
            model: {
                fields: {
                    channels_num: { type: "number" }
                }
            },
            data : function(d) {
                //逻辑代码
            },
            total : function(d) {
                //逻辑代码
            }
        },
        pageSize: _kendoConfigure.pageSize,
        serverPaging: true,
        serverSorting: true,
        serverFiltering: true
    });
    return dataSource;
}

3.git的提问 和 stackoverflow 的提问地址。

stackoverflow

github

阅读 6.4k
1 个回答

http://demos.telerik.com/kend...的示例中可以看到详细的请求方法

点击排序的时候可以看到请求中带有orderby的参数

clipboard.png

而你的setDataSource和refresh的方法应该是jq的方法,angular的数据绑定应该是不会出现这两个操作DOM的方法
你可以参照示例来写
而且我觉得你用的并不是kendo的angular组件

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题