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)
{
// Default _args to an empty array
if (typeof _args != "array")
if (typeof _args == "undefined" || !(_args instanceof Array))
{
_args = [];
}

View File

@ -477,8 +477,6 @@ egwGridColumns.prototype.setTotalWidth = function(_value)
this.totalWidth = _value;
this._calculateWidths();
console.log(this.columnWidths);
}
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 ]
* ELEMENT DATA // See below
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]"
* }
* ]
@ -296,17 +297,35 @@ egwGridDataElement.prototype.loadData = function(_data, _doCallUpdate)
// Inserts a range of given dummy elements into the data tree
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 canHaveChildren = typeof entry.canHaveChildren == "boolean" ? entry.canHaveChildren : false;
var index = last_element ? last_element.index + 1 : 0;
var group = typeof entry.group == "string" ? entry.group : false;
var ids = [];
if (typeof entry.ids != "undefined")
{
ids = entry.ids;
}
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++)
{
var id = prefix + (index + j);
element = this.insertElement(index + j, id);
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.canHaveChildren = canHaveChildren;
if (group !== false)
{
element.set_group(group);
}
}
}
else if (entryType == EGW_DATA_TYPE_ELEMENT)
@ -503,7 +522,8 @@ egwGridDataElement.prototype.hasColumn = function(_columnId, _returnData)
res = {
"caption": this.caption,
"iconUrl": this.iconUrl,
"time": this.capColTime
"time": this.capColTime,
"queued": false
}
}
else
@ -528,7 +548,8 @@ egwGridDataElement.prototype.hasColumn = function(_columnId, _returnData)
var dataSet = (typeof this.data[_columnId] != "undefined");
res = {
"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 (typeof this.data[_columnId] != "undefined")
{
if (_returnData && typeof this.data[_columnId].data != "undefined")
if (_returnData)
{
if (typeof this.data[_columnId].data != "undefined")
{
res = this.data[_columnId];
}
}
else
{
res = true;
res = this.data[_columnId].queued;
}
}
// Probably there is a default value specified for this column...
@ -587,9 +611,16 @@ egwGridDataElement.prototype.getData = function(_columnIds)
if (res !== null)
{
if (res !== false)
{
if (typeof res.queued != "undefined" && res.queued != false)
{
result[_columnIds[i]] = false;
}
else
{
result[_columnIds[i]] = res;
}
}
else
{
queryList.push(_columnIds[i]);
@ -1309,6 +1340,9 @@ egwGridDataQueue.prototype.flushQueue = function(_doPrefetch)
ids.push(id);
}
// Check whether there actually are elements queued...
if (ids.length > 0)
{
// Call the fetch callback and save a snapshot of the current queue
var queue = this.queue;
this.fetchCallback.call(this.context, ids, this.queueColumns, function(_data) {
@ -1319,6 +1353,7 @@ egwGridDataQueue.prototype.flushQueue = function(_doPrefetch)
this.queueColumns = [];
this.timeoutId = 0;
}
}
/**
* Internal function which is called when the data is received from the fetchCallback.