如何在daterangepicker的日期单元格中添加自定义标题

问题描述 投票:2回答:1

我正在使用daterangepicker库作为日历,并希望按日期显示从业者的状态通过使用isCustomDate函数,我可以更新每个日期单元格的CSS

$('#calender').daterangepicker({
        singleDatePicker:true,
        minDate:moment(valid_from),
        maxDate:moment(valid_to),
        locale:{
            format:'DD MMM YYYY'
        },
        isCustomDate:function(date)
        {
            if(absent.indexOf(moment(date).format('YYYY-MM-DD'))>=0)
            {
                return 'bg-danger text-light';
            }
            else if(present.indexOf(moment(date).format('YYYY-MM-DD'))>=0)
            {
                return 'bg-primary text-light';
            }
        },
        isInvalidDate:function(date)
        {
           if(invalid.indexOf(moment(date).format('YYYY-MM-DD'))>=0)
           {
              return true;
            }
        }
});

但是如何为每个单元格添加标题,例如('Absent'或'Present']

jquery momentjs daterangepicker
1个回答
1
投票
$('#calender').daterangepicker({ singleDatePicker:true, minDate:moment(valid_from), maxDate:moment(valid_to), locale:{ format:'DD MMM YYYY' }, isCustomDate:function(date) { if(absent.indexOf(moment(date).format('YYYY-MM-DD'))>=0) { return 'bg-danger text-light absent'; } else if(present.indexOf(moment(date).format('YYYY-MM-DD'))>=0) { return 'bg-primary text-light'; } }, isInvalidDate:function(date) { if(invalid.indexOf(moment(date).format('YYYY-MM-DD'))>=0) { return true; } } });
© www.soinside.com 2019 - 2024. All rights reserved.