@@ -36,6 +36,7 @@ class DataTable extends Widget {
3636 protected $ _emptyMessage ;
3737 protected $ _json ;
3838 protected $ _rowClass ="" ;
39+ protected $ _sortable ;
3940
4041
4142 public function __construct ($ identifier ,$ model ,$ modelInstance =NULL ) {
@@ -91,7 +92,8 @@ public function compile(JsUtils $js=NULL,&$view=NULL){
9192 }
9293
9394 $ table ->setRowCount (0 , \sizeof ($ captions ));
94- $ table ->setHeaderValues ($ captions );
95+ $ this ->_generateHeader ($ table ,$ captions );
96+
9597 if (isset ($ this ->_compileParts ))
9698 $ table ->setCompileParts ($ this ->_compileParts );
9799
@@ -121,6 +123,13 @@ public function compile(JsUtils $js=NULL,&$view=NULL){
121123 return parent ::compile ($ js ,$ view );
122124 }
123125
126+ protected function _generateHeader (HtmlTable $ table ,$ captions ){
127+ $ table ->setHeaderValues ($ captions );
128+ if (isset ($ this ->_sortable )){
129+ $ table ->setSortable ($ this ->_sortable );
130+ }
131+ }
132+
124133
125134
126135 protected function _generateContent ($ table ){
@@ -344,6 +353,10 @@ public function setRefreshSelector($_refreshSelector) {
344353 return $ this ;
345354 }
346355
356+ /**
357+ * {@inheritDoc}
358+ * @see \Ajax\common\Widget::show()
359+ */
347360 public function show ($ modelInstance ){
348361 if (\is_array ($ modelInstance )){
349362 if (\is_array (array_values ($ modelInstance )[0 ]))
@@ -376,6 +389,9 @@ public function setEmptyMessage($_emptyMessage) {
376389 return $ this ;
377390 }
378391
379-
392+ public function setSortable ($ colIndex =NULL ) {
393+ $ this ->_sortable =$ colIndex ;
394+ return $ this ;
395+ }
380396
381397}
0 commit comments