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: ""
],
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
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
走同样的路,发现不同的人生