0

我有一个 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 做到这一点,但我还没有找到一个很好的例子来说明如何做到这一点。

谢谢,艾米

4

1 回答 1

1

您可以遍历上面的对象并适当地设置背景颜色。像这样的东西:

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');
           }

让我知道这是否有帮助!

于 2013-03-28T18:07:48.960 回答