我有一个web服务,每天返回一个颜色,像这样:
({"total_rows":"96","rows":[
{"row":{"date":"2013-01-01","airqualityindex":"50","categorycolorinteger":"-16718848"}},
{"row":{"date":"2013-01-02","airqualityindex":"45","categorycolorinteger":"-16718848"}},
{"row":{"date":"2013-01-03","airqualityindex":"57","categorycolorinteger":"-256"}},
{"row":{"date":"2013-01-04","airqualityindex":"36","categorycolorinteger":"-16718848"}},
{"row":{"date":"2013-01-05","airqualityindex":"42","categorycolorinteger":"-16718848"}},
{"row":{"date":"2013-01-06","airqualityindex":"51","categorycolorinteger":"-256"}}
...]})
我想使用从这个web服务返回的categorycolorinteger为每个单元格的背景颜色添加阴影。我想我也许可以用dayRender做到这一点,但我还没有找到一个很好的例子来说明如何做到这一点。
谢谢,艾米
您可以在上面的对象中循环并设置适当的background-color。像这样:
dayRender: function(date, cell) {
// loop through your object here
// here the date 2013-03-01 and the color red are passed from your loop
if($.fullCalendar.formatDate(date, 'yyyy-MM-dd') === "2013-03-01")
cell.css('background-color', 'red');
}
如果有帮助,请告诉我!