diff --git a/workflow/engine/methods/processCategory/processCategory_Ajax.php b/workflow/engine/methods/processCategory/processCategory_Ajax.php index 54cef67b5..a96baf10c 100755 --- a/workflow/engine/methods/processCategory/processCategory_Ajax.php +++ b/workflow/engine/methods/processCategory/processCategory_Ajax.php @@ -35,6 +35,8 @@ if (isset( $_REQUEST['action'] )) { $start = isset( $_POST['start'] ) ? $_POST['start'] : 0; $limit = isset( $_POST['limit'] ) ? $_POST['limit'] : $limit_size; $filter = isset( $_REQUEST['textFilter'] ) ? $_REQUEST['textFilter'] : ''; + $dir = isset( $_POST['dir'] ) ? $_POST['dir'] : 'ASC'; + $sort = isset( $_POST['sort'] ) ? $_POST['sort'] : 'CATEGORY_NAME'; $oCriteria = new Criteria( 'workflow' ); $oCriteria->addSelectColumn( 'COUNT(*) AS CNT' ); @@ -55,6 +57,13 @@ if (isset( $_REQUEST['action'] )) { if ($filter != '') { $oCriteria->add( ProcessCategoryPeer::CATEGORY_NAME, '%' . $filter . '%', Criteria::LIKE ); } + + if ($dir == "DESC") { + $oCriteria->addDescendingOrderByColumn($sort); + } else { + $oCriteria->addAscendingOrderByColumn($sort); + } + $oCriteria->setLimit( $limit ); $oCriteria->setOffset( $start ); $oDataset = ProcessCategoryPeer::doSelectRS( $oCriteria ); @@ -62,14 +71,16 @@ if (isset( $_REQUEST['action'] )) { $proc = new Process(); $aProcess = $proc->getAllProcessesByCategory(); - + $result = ""; $aCat = array (); while ($oDataset->next()) { $aCat[] = $oDataset->getRow(); $index = sizeof( $aCat ) - 1; $aCat[$index]['TOTAL_PROCESSES'] = isset( $aProcess[$aCat[$index]['CATEGORY_UID']] ) ? $aProcess[$aCat[$index]['CATEGORY_UID']] : 0; } - echo '{categories: ' . G::json_encode( $aCat ) . ', total_categories: ' . $total_categories . '}'; + $result['data'] = $aCat; + $result['totalCount'] = $total_categories; + echo G::json_encode( $result ); break; case 'updatePageSize': G::LoadClass( 'configuration' ); diff --git a/workflow/engine/templates/processCategory/processCategoryList.js b/workflow/engine/templates/processCategory/processCategoryList.js index 1b76bac04..b3de47df1 100755 --- a/workflow/engine/templates/processCategory/processCategoryList.js +++ b/workflow/engine/templates/processCategory/processCategoryList.js @@ -160,13 +160,14 @@ Ext.onReady(function(){ } }); - store = new Ext.data.GroupingStore( { + store = new Ext.data.GroupingStore({ + remoteSort: true, proxy : new Ext.data.HttpProxy({ url: 'processCategory_Ajax?action=processCategoryList' }), - reader : new Ext.data.JsonReader( { - root: 'categories', - totalProperty: 'total_categories', + reader : new Ext.data.JsonReader({ + totalProperty: 'totalCount', + root: 'data', fields : [ {name : 'CATEGORY_UID'}, {name : 'CATEGORY_PARENT'}, @@ -176,7 +177,6 @@ Ext.onReady(function(){ ] }) }); - cmodel = new Ext.grid.ColumnModel({ defaults: { width: 50, @@ -274,7 +274,6 @@ Ext.onReady(function(){ ); infoGrid.addListener('rowcontextmenu',onMessageContextMenu,this); - infoGrid.store.load(); viewport = new Ext.Viewport({