From 4477efd6dcee703faaca708ae7f968d7c8cc1ce8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20St=C3=B6ckel?= Date: Fri, 3 Jun 2011 14:08:49 +0000 Subject: [PATCH] Added possibility to add/remove css classes from individual grid view rows --- phpgwapi/js/egw_action/egw_grid_data.js | 37 ++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/phpgwapi/js/egw_action/egw_grid_data.js b/phpgwapi/js/egw_action/egw_grid_data.js index 16907cd1a0..1f39d402d8 100644 --- a/phpgwapi/js/egw_action/egw_grid_data.js +++ b/phpgwapi/js/egw_action/egw_grid_data.js @@ -117,7 +117,6 @@ egwGridDataElement.prototype.set_iconOverlay = function(_value) } } - egwGridDataElement.prototype.set_iconSize = function(_value) { if (_value != this.iconSize) @@ -218,6 +217,42 @@ egwGridDataElement.prototype.set_data = function(_value) } } +egwGridDataElement.prototype.addClass = function(_value) { + // Split the string into individual classes + classes = this.rowClass.split(' '); + + // Add the given class if it is not already set + if (classes.indexOf(_value) == -1) + { + classes.push(_value); + + // Write the new value + this.rowClass = classes.join(' '); + + // Update the grid element + this.callGridViewObjectUpdate(); + } +} + +egwGridDataElement.prototype.removeClass = function(_value) { + // Split the string into individual classes + classes = this.rowClass.split(' '); + + // Remove the given value if it exists + var idx = classes.indexOf(_value); + if (idx > -1) + { + classes.splice(idx, 1); + + // Write the new value + this.rowClass = classes.join(' '); + + // Update the grid element + this.callGridViewObjectUpdate(); + } +} + + /** * Loads data into the GridData element. This function has two basic operating modes: *