Added selected change event to grid component, reverted change with drag'n'drop and window.top

This commit is contained in:
Andreas Stöckel 2011-03-31 12:17:46 +00:00
parent 3be7eba007
commit b424341afe
7 changed files with 77 additions and 16 deletions

View File

@ -174,6 +174,7 @@ define("EGW_COL_SORTABLE_NONE", 0);
define("EGW_COL_SORTABLE_ALPHABETIC", 1); define("EGW_COL_SORTABLE_ALPHABETIC", 1);
define("EGW_COL_SORTABLE_NUMERICAL", 2); define("EGW_COL_SORTABLE_NUMERICAL", 2);
define("EGW_COL_SORTABLE_NATURAL", 3); define("EGW_COL_SORTABLE_NATURAL", 3);
define("EGW_COL_SORTABLE_EXTERNAL", 4);
define("EGW_COL_SORTMODE_NONE", 0); define("EGW_COL_SORTMODE_NONE", 0);
define("EGW_COL_SORTMODE_ASC", 1); 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), "sortable" => array("types" => "int", "default" => EGW_COL_SORTABLE_NONE),
"sortmode" => array("types" => "int", "default" => EGW_COL_SORTMODE_NONE), "sortmode" => array("types" => "int", "default" => EGW_COL_SORTMODE_NONE),
"default" => array("types" => "string,int", "default" => EGW_COL_DEFAULT_FETCH), "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 // Set the column id

View File

@ -32,12 +32,6 @@ _egwActionClasses["drop"] = {
"implementation": getDropImplementation "implementation": getDropImplementation
} }
function _getTopBody()
{
return $("body", window.top);
}
/** /**
* The egwDragAction class overwrites the egwAction class and adds the new * The egwDragAction class overwrites the egwAction class and adds the new
* "dragType" propery. The "onExecute" event of the drag action will be called * "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 // fixes a bug in IE: If the element isn't inserted into
// the DOM-tree jquery appends it to the parent node. // the DOM-tree jquery appends it to the parent node.
// In case this is a table it doesn't work correctly // In case this is a table it doesn't work correctly
_getTopBody().append(ai.helper); $("body").append(ai.helper);
return ai.helper; return ai.helper;
} }

View File

@ -35,14 +35,25 @@ function egwGrid(_parentNode, _columns, _objectManager, _fetchCallback, _columnC
// Create the read queue // Create the read queue
this.readQueue = new egwGridDataQueue(_fetchCallback, _context); this.readQueue = new egwGridDataQueue(_fetchCallback, _context);
this.selectedChangeCallback = null;
// Create the root data element // Create the root data element
this.dataRoot = new egwGridDataElement("", null, this.columns, this.readQueue, this.dataRoot = new egwGridDataElement("", null, this.columns, this.readQueue,
_objectManager); _objectManager);
var self = this; var self = this;
this.dataRoot.actionObject.setSelectedCallback = function() { 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)
}
} }
}; };

View File

@ -33,6 +33,8 @@ var EGW_COL_SORTABLE_NONE = 0;
var EGW_COL_SORTABLE_ALPHABETIC = 1; var EGW_COL_SORTABLE_ALPHABETIC = 1;
var EGW_COL_SORTABLE_NUMERICAL = 2; var EGW_COL_SORTABLE_NUMERICAL = 2;
var EGW_COL_SORTABLE_NATURAL = 3; var EGW_COL_SORTABLE_NATURAL = 3;
var EGW_COL_SORTABLE_EXTERNAL = 4;
var EGW_COL_SORTMODE_NONE = 0; var EGW_COL_SORTMODE_NONE = 0;
var EGW_COL_SORTMODE_ASC = 1; 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 || if (typeof _value == "number" && (_value == EGW_COL_SORTABLE_ALPHABETIC ||
_value == EGW_COL_SORTABLE_NONE || _value == EGW_COL_SORTABLE_NATURAL || _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) if (_value == EGW_COL_SORTABLE_NONE)
{ {

View File

@ -291,6 +291,31 @@ egwGridViewOuter.prototype.buildBase = function()
this.outer_thead.append(this.outer_head_tr); 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() egwGridViewOuter.prototype.buildBaseHeader = function()
{ {
// Build the "option-column", if this hasn't been done yet // 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 // Create the column element and insert it into the DOM-Tree
var column = $(document.createElement("th")); var column = $(document.createElement("th"));
column.addClass(col.tdClass); column.addClass(col.tdClass);
this.headerColumns.push(column);
var cont = $(document.createElement("div")); var cont = $(document.createElement("div"));
cont.addClass("innerContainer"); cont.addClass("innerContainer");
@ -325,15 +351,23 @@ egwGridViewOuter.prototype.buildBaseHeader = function()
cont.append(this.checkbox); 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); column.append(cont);
this.outer_head_tr.append(column); this.outer_head_tr.append(column);
this.headerColumns.push(column);
} }
// Build the "select columns" icon // Build the "select columns" icon

View File

@ -209,4 +209,21 @@ body, td, th {
border-bottom: 0 none silver !important; 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);
}

View File

@ -42,7 +42,9 @@
"id": "name", "id": "name",
"caption": "Name", "caption": "Name",
"width": "75%", "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", "id": "size",