diff --git a/phpgwapi/inc/class.egw_grid_columns.inc.php b/phpgwapi/inc/class.egw_grid_columns.inc.php index c3a51da9e9..9a1f0345db 100644 --- a/phpgwapi/inc/class.egw_grid_columns.inc.php +++ b/phpgwapi/inc/class.egw_grid_columns.inc.php @@ -174,6 +174,7 @@ define("EGW_COL_SORTABLE_NONE", 0); define("EGW_COL_SORTABLE_ALPHABETIC", 1); define("EGW_COL_SORTABLE_NUMERICAL", 2); define("EGW_COL_SORTABLE_NATURAL", 3); +define("EGW_COL_SORTABLE_EXTERNAL", 4); define("EGW_COL_SORTMODE_NONE", 0); define("EGW_COL_SORTMODE_ASC", 1); @@ -198,7 +199,7 @@ class egw_grid_column extends egw_json_object "sortable" => array("types" => "int", "default" => EGW_COL_SORTABLE_NONE), "sortmode" => array("types" => "int", "default" => EGW_COL_SORTMODE_NONE), "default" => array("types" => "string,int", "default" => EGW_COL_DEFAULT_FETCH), - "type" => array("types" => "int", "default" => EGW_COL_TYPE_DEFAULT), + "type" => array("types" => "int", "default" => EGW_COL_TYPE_DEFAULT) )); // Set the column id diff --git a/phpgwapi/js/egw_action/egw_action_dragdrop.js b/phpgwapi/js/egw_action/egw_action_dragdrop.js index ee2c2d931a..52c839d4d2 100644 --- a/phpgwapi/js/egw_action/egw_action_dragdrop.js +++ b/phpgwapi/js/egw_action/egw_action_dragdrop.js @@ -32,12 +32,6 @@ _egwActionClasses["drop"] = { "implementation": getDropImplementation } -function _getTopBody() -{ - return $("body", window.top); -} - - /** * The egwDragAction class overwrites the egwAction class and adds the new * "dragType" propery. The "onExecute" event of the drag action will be called @@ -117,7 +111,7 @@ function egwDragActionImplementation() // fixes a bug in IE: If the element isn't inserted into // the DOM-tree jquery appends it to the parent node. // In case this is a table it doesn't work correctly - _getTopBody().append(ai.helper); + $("body").append(ai.helper); return ai.helper; } diff --git a/phpgwapi/js/egw_action/egw_grid.js b/phpgwapi/js/egw_action/egw_grid.js index 4b83733b3b..87b42cc42a 100644 --- a/phpgwapi/js/egw_action/egw_grid.js +++ b/phpgwapi/js/egw_action/egw_grid.js @@ -35,14 +35,25 @@ function egwGrid(_parentNode, _columns, _objectManager, _fetchCallback, _columnC // Create the read queue this.readQueue = new egwGridDataQueue(_fetchCallback, _context); + this.selectedChangeCallback = null; + // Create the root data element this.dataRoot = new egwGridDataElement("", null, this.columns, this.readQueue, _objectManager); var self = this; this.dataRoot.actionObject.setSelectedCallback = function() { - if (self.gridOuter.checkbox) + if (self.gridOuter.checkbox || self.selectedChangeCallback) { - self.gridOuter.checkbox.attr("checked", this.getAllSelected()) + var allSelected = this.getAllSelected(); + if (self.gridOuter.checkbox) + { + self.gridOuter.checkbox.attr("checked", allSelected) + } + + if (self.selectedChangeCallback) + { + self.selectedChangeCallback.call(self.context, allSelected) + } } }; diff --git a/phpgwapi/js/egw_action/egw_grid_columns.js b/phpgwapi/js/egw_action/egw_grid_columns.js index 78319ba2ad..3d9d788af1 100644 --- a/phpgwapi/js/egw_action/egw_grid_columns.js +++ b/phpgwapi/js/egw_action/egw_grid_columns.js @@ -33,6 +33,8 @@ var EGW_COL_SORTABLE_NONE = 0; var EGW_COL_SORTABLE_ALPHABETIC = 1; var EGW_COL_SORTABLE_NUMERICAL = 2; var EGW_COL_SORTABLE_NATURAL = 3; +var EGW_COL_SORTABLE_EXTERNAL = 4; + var EGW_COL_SORTMODE_NONE = 0; var EGW_COL_SORTMODE_ASC = 1; @@ -204,7 +206,7 @@ egwGridColumn.prototype.set_sortable = function(_value) { if (typeof _value == "number" && (_value == EGW_COL_SORTABLE_ALPHABETIC || _value == EGW_COL_SORTABLE_NONE || _value == EGW_COL_SORTABLE_NATURAL || - _value == EGW_COL_SORTABLE_NUMERICAL)) + _value == EGW_COL_SORTABLE_NUMERICAL || _value == EGW_COL_SORTABLE_EXTERNAL)) { if (_value == EGW_COL_SORTABLE_NONE) { diff --git a/phpgwapi/js/egw_action/egw_grid_view.js b/phpgwapi/js/egw_action/egw_grid_view.js index 7248477a32..d49cc7d229 100644 --- a/phpgwapi/js/egw_action/egw_grid_view.js +++ b/phpgwapi/js/egw_action/egw_grid_view.js @@ -291,6 +291,31 @@ egwGridViewOuter.prototype.buildBase = function() this.outer_thead.append(this.outer_head_tr); } +egwGridViewOuter.prototype.updateColSortmode = function(_colIdx, _sortArrow) +{ + if (typeof _sortArrow == "undefined") + { + _sortArrow = $("span.sort", this.headerColumns[_colIdx]); + } + + var col = this.columns[_colIdx]; + if (_sortArrow) + { + _sortArrow.removeClass("asc"); + _sortArrow.removeClass("desc"); + + switch (col.sortmode) + { + case EGW_COL_SORTMODE_ASC: + _sortArrow.addClass("asc"); + break; + case EGW_COL_SORTMODE_DESC: + _sortArrow.addClass("desc"); + break; + } + } +} + egwGridViewOuter.prototype.buildBaseHeader = function() { // Build the "option-column", if this hasn't been done yet @@ -306,6 +331,7 @@ egwGridViewOuter.prototype.buildBaseHeader = function() // Create the column element and insert it into the DOM-Tree var column = $(document.createElement("th")); column.addClass(col.tdClass); + this.headerColumns.push(column); var cont = $(document.createElement("div")); cont.addClass("innerContainer"); @@ -325,15 +351,23 @@ egwGridViewOuter.prototype.buildBaseHeader = function() cont.append(this.checkbox); } - else + + var caption = $(document.createElement("span")); + caption.html(col.caption); + + cont.append(caption); + + if (col.type != EGW_COL_TYPE_CHECKBOX && col.sortable != EGW_COL_SORTABLE_NONE) { - cont.html(col.caption); + var sortArrow = $(document.createElement("span")); + sortArrow.addClass("sort"); + cont.append(sortArrow); + + this.updateColSortmode(i, sortArrow); } column.append(cont); this.outer_head_tr.append(column); - - this.headerColumns.push(column); } // Build the "select columns" icon diff --git a/phpgwapi/js/egw_action/test/grid.css b/phpgwapi/js/egw_action/test/grid.css index 8540ebdc16..a3ef7a54b7 100644 --- a/phpgwapi/js/egw_action/test/grid.css +++ b/phpgwapi/js/egw_action/test/grid.css @@ -209,4 +209,21 @@ body, td, th { border-bottom: 0 none silver !important; } +.egwGridView_outer span.sort { + display: inline-block; + width: 7px; + height: 7px; + background-repeat: no-repeat; + background-position: center; + margin: 2px; + vertical-align: middle; +} + +.egwGridView_outer span.sort.asc { + background-image: url(imgs/up.png); +} + +.egwGridView_outer span.sort.desc { + background-image: url(imgs/down.png); +} diff --git a/phpgwapi/js/egw_action/test/test_grid_view.html b/phpgwapi/js/egw_action/test/test_grid_view.html index 51225da8ff..866abb0b91 100644 --- a/phpgwapi/js/egw_action/test/test_grid_view.html +++ b/phpgwapi/js/egw_action/test/test_grid_view.html @@ -42,7 +42,9 @@ "id": "name", "caption": "Name", "width": "75%", - "type": EGW_COL_TYPE_NAME_ICON_FIXED + "type": EGW_COL_TYPE_NAME_ICON_FIXED, + "sortable": EGW_COL_SORTABLE_EXTERNAL, + "sortmode": EGW_COL_SORTMODE_ASC }, { "id": "size",