Javascript 角度jqxSchedular源本地数据可以';不能从远程绑定
我正在尝试将jqxSchedular用于我的web应用程序 Schedular无法从远程数据绑定 这是我的角度分量:Javascript 角度jqxSchedular源本地数据可以';不能从远程绑定,javascript,angular,jqxwidgets,Javascript,Angular,Jqxwidgets,我正在尝试将jqxSchedular用于我的web应用程序 Schedular无法从远程数据绑定 这是我的角度分量: export class CourseScheduleComponent implements OnInit { appointmentDataFields: any = { from: "start", to: "end", description: "description", subject: "subject",
export class CourseScheduleComponent implements OnInit {
appointmentDataFields: any =
{
from: "start",
to: "end",
description: "description",
subject: "subject",
resourceId: "calendar"
};
source = {
dataType: "array",
dataFields: [
{ name: 'id', type: 'string' },
{ name: 'description', type: 'string' },
{ name: 'subject', type: 'string' },
{ name: 'calendar', type: 'string' },
{ name: 'start', type: 'date' },
{ name: 'end', type: 'date' }
],
localData: []
}
resources: any =
{
colorScheme: "scheme04",
dataField: "calendar",
source: new jqx.dataAdapter(this.source)
};
dataAdapter: any;
date: any = new jqx.date();
views: string[] | any[] =
[
'dayView',
'weekView',
'monthView',
'agendaView'
];
constructor(private repository: RepositoryService,private router: Router,
private activeRoute: ActivatedRoute ) { }
ngOnInit() {
this.getCourseSchedules().subscribe(res=>{
this.source.localData = res as CourseSchedule[];
},err=>{
console.log(err);
});
this.dataAdapter = new jqx.dataAdapter(this.source)
}
getCourseSchedules()
{
var courseId : string = this.activeRoute.snapshot.params['id'];
var apiUrl = `/api/course/schedule?courseId=${courseId}`;
return this.repository.getData(apiUrl).pipe(
map(data => {
let schedules = data as CourseSchedule[];
let newSchedules:CourseSchedule[] = [];
schedules.forEach((schedule) => {
const {start,end,...other} = schedule;
newSchedules.push(<CourseSchedule>{
start: new Date(start),
end: new Date(end),
...other
})
});
return newSchedules;
})
);
}
}
导出类CourseScheduleComponent实现OnInit{
任命数据字段:任何=
{
从:“开始”,
致:“结束”,
description:“description”,
主题:“主题”,
resourceId:“日历”
};
来源={
数据类型:“数组”,
数据字段:[
{name:'id',type:'string'},
{name:'description',type:'string'},
{name:'subject',type:'string'},
{name:'calendar',键入:'string'},
{name:'start',键入:'date'},
{name:'end',键入:'date'}
],
本地数据:[]
}
资源:任意=
{
配色方案:“scheme04”,
数据字段:“日历”,
来源:新的jqx.dataAdapter(this.source)
};
数据适配器:任何;
日期:any=new jqx.date();
视图:字符串[]|任意[]=
[
“dayView”,
“weekView”,
“monthView”,
“agendaView”
];
构造函数(专用存储库:RepositoryService,专用路由器:路由器,
专用activeRoute:ActivatedRoute){}
恩戈尼尼特(){
this.getCourseSchedules().subscribe(res=>{
this.source.localData=res as CourseSchedule[];
},err=>{
控制台日志(err);
});
this.dataAdapter=newjqx.dataAdapter(this.source)
}
getCourseSchedules()
{
var courseId:string=this.activeRoute.snapshot.params['id'];
var apirl=`/api/course/schedule?courseId=${courseId}`;
返回此.repository.getData(apiUrl).pipe(
地图(数据=>{
let schedules=数据为CourseSchedule[];
let newSchedules:CourseSchedule[]=[];
附表。forEach((附表)=>{
const{start,end,…other}=调度;
新闻日程表({
开始:新日期(开始),
结束:新日期(结束),
……其他
})
});
返回新闻日程表;
})
);
}
}
调试ngOnInit时,设置localData没有问题。但当我控制日志源时,它显示localdata
为空
我找不到Angular jqxSchedular的远程数据绑定示例
因此,基本上它可以处理本地数据,但在远程则不起作用
请帮忙 您必须使用addAppointment方法从jqx组件添加它们,如下所示:
getCourseSchedules()
{
let self = this;
var courseId : string = this.activeRoute.snapshot.params['id'];
var apiUrl = `/api/course/schedule?courseId=${courseId}`;
return this.repository.getData(apiUrl).pipe(
map(data => {
let schedules = data as CourseSchedule[];
let newSchedules:CourseSchedule[] = [];
schedules.forEach((schedule) => {
const {start,end,...other} = schedule;
var appointment = {
start: new Date(start),
end: new Date(end),
..other
};
self.myScheduler.addAppointment(appointment);
});
})
);
}
有关详细信息,请参阅