File tree Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Original file line number Diff line number Diff line change 1313use yii \helpers \Html ;
1414use yii \helpers \Inflector ;
1515use yii \helpers \Json ;
16- use yii \web \JsExpression ;
1716
1817/**
1918 * Class DataTable
@@ -149,16 +148,18 @@ private function initData()
149148 $ row = [];
150149 foreach ($ this ->_options ['columns ' ] as $ column ) {
151150 if ($ column instanceof DataTableColumn) {
152- $ value = ArrayHelper::getValue ($ obj , $ column ->data );
153- if (($ pos = strrpos ($ column ->data , '. ' )) !== false ) {
154- $ keys = explode ('. ' , $ column ->data );
155- $ a = $ value ;
156- foreach (array_reverse ($ keys ) as $ key ) {
157- $ a = [$ key => $ a ];
151+ if ($ column ->data ) {
152+ $ value = ArrayHelper::getValue ($ obj , $ column ->data );
153+ if (($ pos = strrpos ($ column ->data , '. ' )) !== false ) {
154+ $ keys = explode ('. ' , $ column ->data );
155+ $ a = $ value ;
156+ foreach (array_reverse ($ keys ) as $ key ) {
157+ $ a = [$ key => $ a ];
158+ }
159+ $ row [$ keys [0 ]] = $ a [$ keys [0 ]];
160+ } else {
161+ $ row [$ column ->data ] = $ value ;
158162 }
159- $ row [$ keys [0 ]] = $ a [$ keys [0 ]];
160- } else {
161- $ row [$ column ->data ] = $ value ;
162163 }
163164 }
164165 }
Original file line number Diff line number Diff line change 77
88namespace nullref \datatable ;
99
10+ use yii \base \InvalidConfigException ;
1011use yii \base \Widget ;
1112use yii \helpers \Html ;
1213use yii \helpers \Inflector ;
@@ -64,8 +65,8 @@ public function init()
6465 {
6566 parent ::init ();
6667
67- if ($ this ->data === null ) {
68- throw new InvalidConfigException (get_class ( $ this ) . ' ::$ data must be set. ' );
68+ if ($ this ->data === null && $ this -> render === null ) {
69+ throw new InvalidConfigException (" Either ' data' or 'render' properties must be specified. " );
6970 }
7071
7172 if ($ this ->title === null ) {
You can’t perform that action at this time.
0 commit comments