完整日历计划程序 - 获取ResourceId选择用于添加事件的插槽

时间:2015-10-21 02:25:29

标签: fullcalendar scheduler

在Scheduler Calendar中,Iam从第一列的resources.json获取资源。 我试图为每个资源添加事件。 当我直接点击每个资源的插槽时,我应该得到resourceId。所以,我知道哪些资源,Iam添加了事件。

在select函数中,我只能获得开始和结束时间,但不能获得resourceId。

任何帮助都将受到高度赞赏。

1 个答案:

答案 0 :(得分:0)

select回调中有第四个参数,使用它可以获得资源。见下面的例子。

$('#calendar').fullCalendar({
select: function (start, end, calendar,res) 
{
     //to get resource 
    console.log(res);
}
});

它会给你json对象。

要在点击资源标题时获取资源ID,请在scheduler.js中执行以下更改, 修改下面的method.add id和类到资源头。

 ResourceRow.prototype.renderSpreadsheetContent = function(tr) {
 .......
 .......
     td = $('<td id="'+resource.id+'" class="' + this.view.widgetContentClass + ' resourceHeader"/>').append(contentEl); // add id and class to the resource header.
 .......
 .......
   }

更改代码后,只需在js文件中绑定一个事件,如下所示

     $(".resourceHeader").click(function(){
      var   resourceId=$(this).attr("id");
      //write a code to get all the events of selected resource 
      //and render it on calendar
     });

你现在好了。 感谢