columns = $this->getConfig('columns', []); } /** * Renders the widget. */ public function render() { $this->prepareVars(); return $this->makePartial('table'); } /** * Prepares the view data */ public function prepareVars() { $this->vars['columns'] = $this->prepareColumnsArray(); } // // Internals // /** * {@inheritDoc} */ public function loadAssets() { $this->addCss('css/table.css', 'core'); $this->addJs('js/table.js', 'core'); $this->addJs('js/table.helper.navigation.js', 'core'); $this->addJs('js/table.datasource.base.js', 'core'); $this->addJs('js/table.datasource.client.js', 'core'); $this->addJs('js/table.processor.base.js', 'core'); $this->addJs('js/table.processor.string.js', 'core'); $this->addJs('js/table.processor.checkbox.js', 'core'); $this->addJs('js/table.processor.dropdown.js', 'core'); } /** * Converts the columns associative array to a regular array. * Working with regular arrays is much faster in JavaScript. * References: * - http://www.smashingmagazine.com/2012/11/05/writing-fast-memory-efficient-javascript/ * - http://jsperf.com/performance-of-array-vs-object/3 */ protected function prepareColumnsArray() { $result = []; foreach ($this->columns as $key=>$data) { $data['key'] = $key; $result[] = $data; } return $result; } }