Fixed serious bug in egw_grid_data.js/egw_grid_common.js which caused prefetching not to work - instead a request was sent for each element. Added possibility to specify an array ids instead of a count for creating a range of egw_grid data elements (see comment for the egwGridDataElement.loadData, fixed bug which caused the 'queued' image to be removed immediately after it was shown.

This commit is contained in:
Andreas Stöckel 2011-04-14 20:44:29 +00:00
parent 16f9f37576
commit c5cd3a354b
3 changed files with 55 additions and 22 deletions

View File

@ -210,7 +210,7 @@ egwEventQueue.prototype.flush = function()
egwEventQueue.prototype.queue = function(_proc, _context, _args, _id) egwEventQueue.prototype.queue = function(_proc, _context, _args, _id)
{ {
// Default _args to an empty array // Default _args to an empty array
if (typeof _args != "array") if (typeof _args == "undefined" || !(_args instanceof Array))
{ {
_args = []; _args = [];
} }

View File

@ -477,8 +477,6 @@ egwGridColumns.prototype.setTotalWidth = function(_value)
this.totalWidth = _value; this.totalWidth = _value;
this._calculateWidths(); this._calculateWidths();
console.log(this.columnWidths);
} }
egwGridColumns.prototype.getColumnIndexById = function(_id) egwGridColumns.prototype.getColumnIndexById = function(_id)

View File

@ -233,7 +233,8 @@ egwGridDataElement.prototype.set_data = function(_value)
* "children": [ Objects which will be added to the children of the element ] * "children": [ Objects which will be added to the children of the element ]
* ELEMENT DATA // See below * ELEMENT DATA // See below
IF EGW_DATA_TYPE_RANGE: IF EGW_DATA_TYPE_RANGE:
"count": [Count of Elements], "count": [Count of Elements], | "ids": [ Array with element ids ],
"group": [ Action Link Group to which the generated objects should be added ]
"prefix": "[String prefix which will be added to each element including their index in the list]" "prefix": "[String prefix which will be added to each element including their index in the list]"
* } * }
* ] * ]
@ -296,17 +297,35 @@ egwGridDataElement.prototype.loadData = function(_data, _doCallUpdate)
// Inserts a range of given dummy elements into the data tree // Inserts a range of given dummy elements into the data tree
if (entryType == EGW_DATA_TYPE_RANGE) if (entryType == EGW_DATA_TYPE_RANGE)
{ {
var count = typeof entry.count == "number" && entry.count >= 0 ? entry.count : 1;
var prefix = typeof entry.prefix == "string" ? entry.prefix : "elem_"; var prefix = typeof entry.prefix == "string" ? entry.prefix : "elem_";
var canHaveChildren = typeof entry.canHaveChildren == "boolean" ? entry.canHaveChildren : false; var canHaveChildren = typeof entry.canHaveChildren == "boolean" ? entry.canHaveChildren : false;
var index = last_element ? last_element.index + 1 : 0; var index = last_element ? last_element.index + 1 : 0;
var group = typeof entry.group == "string" ? entry.group : false;
var ids = [];
for (var j = 0; j < count; j++) if (typeof entry.ids != "undefined")
{ {
var id = prefix + (index + j); ids = entry.ids;
element = this.insertElement(index + j, id); }
else if (typeof entry.count != "undefined")
{
var count = typeof entry.count == "number" && entry.count >= 0 ? entry.count : 1;
for (var j = 0; j < count; j++)
{
ids.push(prefix + (index + j));
}
}
for (var j = 0; j < ids.length; j++)
{
element = this.insertElement(index + j, ids[j]);
element.type = type; // Type can only be set directly after creation element.type = type; // Type can only be set directly after creation
element.canHaveChildren = canHaveChildren; element.canHaveChildren = canHaveChildren;
if (group !== false)
{
element.set_group(group);
}
} }
} }
else if (entryType == EGW_DATA_TYPE_ELEMENT) else if (entryType == EGW_DATA_TYPE_ELEMENT)
@ -503,7 +522,8 @@ egwGridDataElement.prototype.hasColumn = function(_columnId, _returnData)
res = { res = {
"caption": this.caption, "caption": this.caption,
"iconUrl": this.iconUrl, "iconUrl": this.iconUrl,
"time": this.capColTime "time": this.capColTime,
"queued": false
} }
} }
else else
@ -528,7 +548,8 @@ egwGridDataElement.prototype.hasColumn = function(_columnId, _returnData)
var dataSet = (typeof this.data[_columnId] != "undefined"); var dataSet = (typeof this.data[_columnId] != "undefined");
res = { res = {
"data": dataSet ? this.data[_columnId].data : 0, "data": dataSet ? this.data[_columnId].data : 0,
"time": dataSet ? this.data[_columnId].time : this.capColTime "time": dataSet ? this.data[_columnId].time : this.capColTime,
"queued": false
} }
} }
} }
@ -538,13 +559,16 @@ egwGridDataElement.prototype.hasColumn = function(_columnId, _returnData)
// if yes, return it. // if yes, return it.
if (typeof this.data[_columnId] != "undefined") if (typeof this.data[_columnId] != "undefined")
{ {
if (_returnData && typeof this.data[_columnId].data != "undefined") if (_returnData)
{ {
res = this.data[_columnId]; if (typeof this.data[_columnId].data != "undefined")
{
res = this.data[_columnId];
}
} }
else else
{ {
res = true; res = this.data[_columnId].queued;
} }
} }
// Probably there is a default value specified for this column... // Probably there is a default value specified for this column...
@ -588,7 +612,14 @@ egwGridDataElement.prototype.getData = function(_columnIds)
{ {
if (res !== false) if (res !== false)
{ {
result[_columnIds[i]] = res; if (typeof res.queued != "undefined" && res.queued != false)
{
result[_columnIds[i]] = false;
}
else
{
result[_columnIds[i]] = res;
}
} }
else else
{ {
@ -1309,15 +1340,19 @@ egwGridDataQueue.prototype.flushQueue = function(_doPrefetch)
ids.push(id); ids.push(id);
} }
// Call the fetch callback and save a snapshot of the current queue // Check whether there actually are elements queued...
var queue = this.queue; if (ids.length > 0)
this.fetchCallback.call(this.context, ids, this.queueColumns, function(_data) { {
this.dataCallback(_data, queue); // Call the fetch callback and save a snapshot of the current queue
}, this); var queue = this.queue;
this.fetchCallback.call(this.context, ids, this.queueColumns, function(_data) {
this.dataCallback(_data, queue);
}, this);
this.queue = []; this.queue = [];
this.queueColumns = []; this.queueColumns = [];
this.timeoutId = 0; this.timeoutId = 0;
}
} }
/** /**