public function testHtmlException()
 {
     $button = new Button();
     $this->setExpectedException('InvalidArgumentException');
     $button->toHtml(array());
 }
    /**
     *
     * @return \ZfcDatagrid\Datagrid
     */
    private function getGrid()
    {
        /* @var $grid \ZfcDatagrid\Datagrid */
        $grid = $this->getServiceLocator()->get('ZfcDatagrid\\Datagrid');
        $grid->setTitle('Categories');
        $grid->setDefaultItemsPerPage(5);
        $grid->setDataSource($this->getServiceLocator()->get('zfcDatagrid.examples.data.phpArray')->getCategorys());
        $col = new Column\Select('id');
        $col->setIdentity();
        $grid->addColumn($col);
        $colParentId = new Column\Select('parentId');
        $colParentId->setHidden(true);
        $grid->addColumn($colParentId);
        $colHasChildren = new Column\Select('hasChildren');
        $colHasChildren->setHidden(true);
        $grid->addColumn($colHasChildren);
        $colTags = new Column\Select('tags');
        $colTags->setLabel('Tags');
        $colTags->setHidden(true);
        $colTags->setWidth(30);
        $colTags->setType(new Type\PhpArray());
        $grid->addColumn($colTags);
        $toggle = new Column\Action\Button();
        $toggle->setLabel('+');
        $toggle->addShowOnValue($colHasChildren, 'y');
        $toggle->setAttribute('onclick', 'console.log($(this).parent().parent().attr(\'id\'));$.get(\'/zfcDatagrid/category/tree\', function (data) {
            console.log(this);
            $.each(data.data, function (index, value) {
                $(\'#' . $grid->getId() . '\').jqGrid(\'addRowData\', value.idConcated, value, \'after\', 5);
             });
        });');
        $col = new Column\Action();
        $col->setLabel(' ');
        $col->setUniqueId('expandAction');
        $col->addAction($toggle);
        $grid->addColumn($col);
        $col = new Column\Select('name');
        $col->setLabel('Name');
        $col->setWidth(50);
        $col->setSortDefault(1);
        $col->setRendererParameter('formatter', '
            function (cellvalue, options, rowObject) {
                var valuePrint = cellvalue;

                $.each(rowObject.' . $colTags->getUniqueId() . ', function (index, value) {
                    valuePrint += \' <span class="label">\' + value + \'</span>\';
                });

                return valuePrint;
            }
        ', 'jqGrid');
        $grid->addColumn($col);
        $toggle = new Column\Action\Button();
        $toggle->setLabel('other action...');
        $toggle->addShowOnValue($colHasChildren, 'y');
        $toggle->setAttribute('onclick', 'alert(\'clicked\');');
        $col = new Column\Action();
        //         $col->setLabel('A');
        $col->addAction($toggle);
        $grid->addColumn($col);
        return $grid;
    }
 private function getGrid()
 {
     die('xxx');
     /* @var $grid \ZfcDatagrid\Datagrid */
     $grid = $this->getServiceLocator()->get('ZfcDatagrid\\Datagrid');
     $grid->setTitle('Persons');
     $grid->setDefaultItemsPerPage(5);
     $grid->setDataSource($this->getServiceLocator()->get('zfcDatagrid.examples.data.phpArray')->getPersons());
     $col = new Column\Select('id');
     $col->setIdentity();
     $grid->addColumn($col);
     $action = new Action\Mass();
     $action->setTitle('test');
     $action->setLink('/test');
     $grid->addMassAction($action);
     /**
      * Gravatar example
      * - take the email from the datasource
      * - object makes the rest :-)
      *
      * @note Could be whatever you want -> Grab data from everywhere you want with dynamic parameters :-)
      */
     $colEmail = new Column\Select('email');
     $colEmail->setLabel('E-Mail');
     $colEmail->setHidden(true);
     $grid->addColumn($colEmail);
     $dataPopulation = new Column\DataPopulation\Object();
     $dataPopulation->setObject(new Column\DataPopulation\Object\Gravatar());
     $dataPopulation->addObjectParameterColumn('email', $colEmail);
     $col = new Column\ExternalData('avatar');
     $col->setLabel('Avatar');
     $col->setDataPopulation($dataPopulation);
     $col->setType(new Type\Image());
     $grid->addColumn($col);
     $col = new Column\Select('displayName');
     $col->setLabel('Displayname');
     $col->setWidth(25);
     $col->setSortDefault(1, 'ASC');
     $col->setFormatter(new Email());
     $col->addStyle(new Style\Bold());
     $grid->addColumn($col);
     $col = new Column\Select('familyName');
     $col->setLabel('Familyname');
     $col->setWidth(15);
     $grid->addColumn($col);
     $col = new Column\Select('givenName');
     $col->setLabel('Givenname');
     $col->setWidth(15);
     $col->setSortDefault(2, 'DESC');
     $grid->addColumn($col);
     $style = new Style\BackgroundColor(array(200, 200, 200));
     $style->addByValue($col, 'Martin');
     $grid->addRowStyle($style);
     $col = new Column\Select('gender');
     $col->setLabel('Gender');
     $col->setWidth(10);
     $col->setReplaceValues(array('m' => 'male', 'f' => 'female'));
     $style = new Style\BackgroundColor(array(200, 100, 100));
     $style->addByValue($col, 'male');
     $col->addStyle($style);
     $col->setTranslationEnabled(true);
     $grid->addColumn($col);
     $col = new Column\Select('age');
     $col->setLabel('Age');
     $col->setWidth(5);
     $col->setType(new Type\Number());
     $col->setFilterDefaultValue('>=20');
     $style = new Style\Color(Style\Color::$RED);
     $style->addByValue($col, 20);
     $col->addStyle($style);
     $grid->addColumn($col);
     $colType = new Type\Number();
     $colType->addAttribute(\NumberFormatter::FRACTION_DIGITS, 2);
     $colType->setSuffix(' kg');
     $col = new Column\Select('weight');
     $col->setLabel('Weight');
     $col->setWidth(10);
     $col->setType($colType);
     $col->setFilterDefaultOperation(\ZfcDatagrid\Filter::GREATER_EQUAL);
     $grid->addColumn($col);
     $col = new Column\Select('birthday');
     $col->setLabel('Birthday');
     $col->setWidth(10);
     $col->setType(new Type\DateTime());
     $col->setUserSortDisabled(true);
     $grid->addColumn($col);
     $colType = new Type\DateTime('Y-m-d H:i:s', \IntlDateFormatter::MEDIUM, \IntlDateFormatter::MEDIUM);
     $colType->setSourceTimezone('Europe/Vienna');
     $colType->setOutputTimezone('UTC');
     $col = new Column\Select('changeDate');
     $col->setLabel('Last change');
     $col->setWidth(15);
     $col->setType($colType);
     $grid->addColumn($col);
     $action = new Column\Action\Button();
     $action->setLabel('test');
     $action->setAttribute('href', '/someAction/id/' . $action->getRowIdPlaceholder());
     $col = new Column\Action();
     $col->setLabel('Actions');
     $col->setWidth(10);
     $col->addAction($action);
     $grid->addColumn($col);
     $grid->setRowClickAction($action);
     return $grid;
 }