Skip to content

Commit b6900bf

Browse files
#9 fix columns initialization
1 parent 31c2166 commit b6900bf

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"jquery",
1111
"datatable",
1212
"datatables",
13-
"plugin"
13+
"plugin",
14+
"jQuery"
1415
],
1516
"license": "MIT",
1617
"authors": [

src/DataTable.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* @copyright Copyright (c) 2014 Serhiy Vinichuk
3+
* @copyright Copyright (c) 2015 Serhiy Vinichuk
44
* @license MIT
55
* @author Serhiy Vinichuk <[email protected]>
66
*/
@@ -99,7 +99,7 @@ class DataTable extends Widget
9999
public function init()
100100
{
101101
parent::init();
102-
DataTableAsset::register($this->view);
102+
DataTableAsset::register($this->getView());
103103
$this->initColumns();
104104
}
105105

@@ -109,7 +109,7 @@ public function run()
109109
echo Html::beginTag('table', ArrayHelper::merge(['id' => $id], $this->tableOptions));
110110

111111
echo Html::endTag('table');
112-
$this->view->registerJs('jQuery("#' . $id . '").DataTable(' . Json::encode($this->getParams()) . ');');
112+
$this->getView()->registerJs('jQuery("#' . $id . '").DataTable(' . Json::encode($this->getParams()) . ');');
113113
}
114114

115115
protected function getParams()
@@ -119,10 +119,10 @@ protected function getParams()
119119

120120
protected function initColumns()
121121
{
122-
if (isset($this->columns)) {
123-
foreach ($this->columns as $key => $value) {
122+
if (isset($this->_options['columns'])) {
123+
foreach ($this->_options['columns'] as $key => $value) {
124124
if (is_string($value)) {
125-
$this->columns[$key] = ['data' => $value, 'title' => Inflector::camel2words($value)];
125+
$this->_options['columns'][$key] = ['data' => $value, 'title' => Inflector::camel2words($value)];
126126
}
127127
if (isset($value['type'])) {
128128
if ($value['type'] == 'link') {
@@ -131,7 +131,7 @@ protected function initColumns()
131131
}
132132
if (isset($value['class'])) {
133133
$column = \Yii::createObject($value);
134-
$this->columns[$key] = $column;
134+
$this->_options['columns'][$key] = $column;
135135
}
136136
}
137137
}

0 commit comments

Comments
 (0)