11<?php
22/**
3- * @copyright Copyright (c) 2014 Serhiy Vinichuk
3+ * @copyright Copyright (c) 2015 Serhiy Vinichuk
44 * @license MIT
55 * @author Serhiy Vinichuk <serhiyvinichuk@gmail.com>
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