1
1
<?php
2
2
/**
3
- * @copyright Copyright (c) 2014 Serhiy Vinichuk
3
+ * @copyright Copyright (c) 2015 Serhiy Vinichuk
4
4
* @license MIT
5
5
* @author Serhiy Vinichuk <[email protected] >
6
6
*/
@@ -99,7 +99,7 @@ class DataTable extends Widget
99
99
public function init ()
100
100
{
101
101
parent ::init ();
102
- DataTableAsset::register ($ this ->view );
102
+ DataTableAsset::register ($ this ->getView () );
103
103
$ this ->initColumns ();
104
104
}
105
105
@@ -109,7 +109,7 @@ public function run()
109
109
echo Html::beginTag ('table ' , ArrayHelper::merge (['id ' => $ id ], $ this ->tableOptions ));
110
110
111
111
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 ()) . '); ' );
113
113
}
114
114
115
115
protected function getParams ()
@@ -119,10 +119,10 @@ protected function getParams()
119
119
120
120
protected function initColumns ()
121
121
{
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 ) {
124
124
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 )];
126
126
}
127
127
if (isset ($ value ['type ' ])) {
128
128
if ($ value ['type ' ] == 'link ' ) {
@@ -131,7 +131,7 @@ protected function initColumns()
131
131
}
132
132
if (isset ($ value ['class ' ])) {
133
133
$ column = \Yii::createObject ($ value );
134
- $ this ->columns [$ key ] = $ column ;
134
+ $ this ->_options [ ' columns ' ] [$ key ] = $ column ;
135
135
}
136
136
}
137
137
}
0 commit comments