/** * Load the dataGrid */ private function loadDataGrid() { // filter category if ($this->categoryId != null) { // create datagrid $this->dgProducts = new BackendDataGridDB(BackendCatalogModel::QRY_DATAGRID_BROWSE_FOR_CATEGORY, array($this->categoryId, BL::getWorkingLanguage())); // set the URL $this->dgProducts->setURL('&category=' . $this->categoryId, true); } else { // dont filter category // create datagrid $this->dgProducts = new BackendDataGridDB(BackendCatalogModel::QRY_DATAGRID_BROWSE, array(BL::getWorkingLanguage())); } // our JS needs to know an id, so we can highlight it $this->dgProducts->setRowAttributes(array('id' => 'row-[id]')); $this->dgProducts->enableSequenceByDragAndDrop(); $this->dgProducts->setColumnsHidden(array('category_id', 'sequence')); // check if this action is allowed if (BackendAuthentication::isAllowedAction('Edit')) { // set column URLs $this->dgProducts->setColumnURL('title', BackendModel::createURLForAction('edit') . '&id=[id]&category=' . $this->categoryId); // add edit and media column //$this->dgProducts->addColumn('media', null, BL::lbl('Media'), BackendModel::createURLForAction('media') . '&id=[id]', BL::lbl('Media')); $this->dgProducts->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit') . '&id=[id]&category=' . $this->categoryId, BL::lbl('Edit')); // set media column function $this->dgProducts->setColumnFunction(array(__CLASS__, 'setMediaLink'), array('[id]'), 'media'); } }
/** * Adds a new column with a custom action button * * @param string $name The name for the new column. * @param string $label The label for the column. * @param string $value The value for the column. * @param string $url The URL for the link inside the column. * @param string $title The title for the link inside the column. * @param array $anchorAttributes The attributes for the anchor inside the column. * @param string $image An URL to the image inside the column. * @param int $sequence The sequence for the column. */ public function addColumnAction($name, $label = null, $value = null, $url = null, $title = null, $anchorAttributes = null, $image = null, $sequence = null) { // reserve var for attributes $attributes = ''; $icon = $this->decideIcon($name); // no anchorAttributes set means we set the default class attribute for the anchor if (empty($anchorAttributes)) { $anchorAttributes['class'] = 'btn btn-default btn-xs'; } // loop the attributes, build our attributes string foreach ($anchorAttributes as $attribute => $attributeValue) { $attributes .= ' ' . $attribute . '="' . $attributeValue . '"'; } // rebuild value $value = '<a href="' . $url . '"' . $attributes . '>' . ($icon ? '<span class="fa ' . $icon . '"></span> ' : '') . $value . '</a>'; // add the column to the datagrid parent::addColumn($name, $label, $value, null, $title, $image, $sequence); // set column attributes $this->setColumnAttributes($name, array('class' => 'fork-data-grid-action action' . \SpoonFilter::toCamelCase($name), 'style' => 'width: 10%;')); // set header attributes $this->setColumnHeaderAttributes($name, array('class' => $name)); }
/** * Adds a new column with a custom action button * * @param string $name The name for the new column. * @param string[optional] $label The label for the column. * @param string[optional] $value The value for the column. * @param string[optional] $URL The URL for the link inside the column. * @param string[optional] $title The title for the link inside the column. * @param array[optional] $anchorAttributes The attributes for the anchor inside the column. * @param string[optional] $image An URL to the image inside the column. * @param int[optional] $sequence The sequence for the column. */ public function addColumnAction($name, $label = null, $value = null, $URL = null, $title = null, $anchorAttributes = null, $image = null, $sequence = null) { // reserve var for attributes $attributes = ''; // no anchorAttributes set means we set the default class attribute for the anchor if (empty($anchorAttributes)) { $anchorAttributes['class'] = 'button icon icon' . SpoonFilter::toCamelCase($name) . ' linkButton'; } // loop the attributes, build our attributes string foreach ($anchorAttributes as $attribute => $attributeValue) { $attributes .= ' ' . $attribute . '="' . $attributeValue . '"'; } // rebuild value $value = '<a href="' . $URL . '"' . $attributes . '> <span>' . $value . '</span> </a>'; // add the column to the datagrid parent::addColumn($name, $label, $value, null, $title, $image, $sequence); // set column attributes $this->setColumnAttributes($name, array('class' => 'action action' . SpoonFilter::toCamelCase($name), 'style' => 'width: 10%;')); // set header attributes $this->setColumnHeaderAttributes($name, array('class' => $name)); }