CheckBox grid

Hi,

I’m trying to output a table with days of the week and the time of the day (morning, afternoon, evening) of checkBoxes. This represent the availability of users in those periods.

I’m having trouble on representing this table, CCheckBoxColumns seems what I’m looking for but still wont work as I expected.

I wanted to store the structure in an array but CGridView wants models so I’ve created the DB table and model but still cant render the day name on the column header and the time of the day with the checkbox that would select all row boxes.

Also I would like it to change checkboxes with colors (green=>checked, default=>unchecked).

I’ve seen around something that I would like as my final result, I’m attaching a web-shoot of it:

if you click for instance morning it selects all the row boxes and the same for the column day name

Any hint?




CREATE TABLE IF NOT EXISTS availability (

  period varchar(9) NOT NULL,

  monday BOOLEAN NOT NULL DEFAULT 0,

  tuesday BOOLEAN NOT NULL DEFAULT 0,

  wednesday BOOLEAN NOT NULL DEFAULT 0,

  thursday BOOLEAN NOT NULL DEFAULT 0,

  friday BOOLEAN NOT NULL DEFAULT 0,

  saturday BOOLEAN NOT NULL DEFAULT 0,

  sunday BOOLEAN NOT NULL DEFAULT 0

)ENGINE=InnoDB DEFAULT CHARSET=utf8;


INSERT INTO `test`.`availability` (`period`, `monday`, `tuesday`, `wednesday`, `thursday`, `friday`, `saturday`, `sunday`) VALUES ('morning', 0, 0, 0, 0, 0, 0, 0), ('afternoon', 0, 0, 0, 0, 0, 0, 0), ('evening', 0, 0, 0, 0, 0, 0, 0);






$dataProvider = new CActiveDataProvider('Availability');

$this->widget('zii.widgets.grid.CGridView', array(

    'id' => 'availability',

    'dataProvider'=>$dataProvider,

    'columns'=>array(

        'monday'=>array(

            'class'=>'CCheckBoxColumn',

            'selectableRows'=>3,

        ),

    ),

));



Couldn’t solve my problem so I’ve made an extension myself.

http://www.yiiframework.com/extension/availability/

Please feedback ;)