@@ -36,6 +36,7 @@ class DataTable extends Widget {
36
36
protected $ _emptyMessage ;
37
37
protected $ _json ;
38
38
protected $ _rowClass ="" ;
39
+ protected $ _sortable ;
39
40
40
41
41
42
public function __construct ($ identifier ,$ model ,$ modelInstance =NULL ) {
@@ -91,7 +92,8 @@ public function compile(JsUtils $js=NULL,&$view=NULL){
91
92
}
92
93
93
94
$ table ->setRowCount (0 , \sizeof ($ captions ));
94
- $ table ->setHeaderValues ($ captions );
95
+ $ this ->_generateHeader ($ table ,$ captions );
96
+
95
97
if (isset ($ this ->_compileParts ))
96
98
$ table ->setCompileParts ($ this ->_compileParts );
97
99
@@ -121,6 +123,13 @@ public function compile(JsUtils $js=NULL,&$view=NULL){
121
123
return parent ::compile ($ js ,$ view );
122
124
}
123
125
126
+ protected function _generateHeader (HtmlTable $ table ,$ captions ){
127
+ $ table ->setHeaderValues ($ captions );
128
+ if (isset ($ this ->_sortable )){
129
+ $ table ->setSortable ($ this ->_sortable );
130
+ }
131
+ }
132
+
124
133
125
134
126
135
protected function _generateContent ($ table ){
@@ -344,6 +353,10 @@ public function setRefreshSelector($_refreshSelector) {
344
353
return $ this ;
345
354
}
346
355
356
+ /**
357
+ * {@inheritDoc}
358
+ * @see \Ajax\common\Widget::show()
359
+ */
347
360
public function show ($ modelInstance ){
348
361
if (\is_array ($ modelInstance )){
349
362
if (\is_array (array_values ($ modelInstance )[0 ]))
@@ -376,6 +389,9 @@ public function setEmptyMessage($_emptyMessage) {
376
389
return $ this ;
377
390
}
378
391
379
-
392
+ public function setSortable ($ colIndex =NULL ) {
393
+ $ this ->_sortable =$ colIndex ;
394
+ return $ this ;
395
+ }
380
396
381
397
}
0 commit comments