fixed AB "looses" name/organisation column after changing sorting, caused by grid not instanciating disabled rows as children and therefore column-name changes with sorting

added _getColumnName implementation to grid, which takes all nextmatch-* widgets into account (like old eTemplate did) and therefore does not change when sorting changed header-order by disabling of rows
This commit is contained in:
Ralf Becker 2014-01-27 11:06:44 +00:00
parent 50b34a7b99
commit 2685f4d46e

View File

@ -428,6 +428,11 @@ var et2_grid = et2_DOMWidget.extend([et2_IDetachedDOM, et2_IAligned],
cell.align = node.getAttribute("align");
}
// store id of nextmatch-*headers, so it is available for disabled widgets, which get not instanciated
if (nodeName.substr(0, 10) == 'nextmatch-')
{
cell.nm_id = node.getAttribute('id');
}
// Apply widget's class to td, for backward compatability
if(node.getAttribute("class"))
{
@ -574,6 +579,8 @@ var et2_grid = et2_DOMWidget.extend([et2_IDetachedDOM, et2_IAligned],
* As the does not fit very well into the default widget structure, we're
* overwriting the loadFromXML function and doing a two-pass reading -
* in the first step the
*
* @param {object} _node xml node to process
*/
loadFromXML: function(_node) {
// Keep the node for later changing / reloading
@ -847,7 +854,7 @@ var et2_grid = et2_DOMWidget.extend([et2_IDetachedDOM, et2_IAligned],
/**
* Override parent to apply actions on each row
*
* @param Object[ {ID: attributes..}+] as for set_actions
* @param {array} actions [ {ID: attributes..}+] as for set_actions
*/
_link_actions: function(actions)
{
@ -886,6 +893,8 @@ var et2_grid = et2_DOMWidget.extend([et2_IDetachedDOM, et2_IAligned],
* Code for implementing et2_IDetachedDOM
* This doesn't need to be implemented.
* Individual widgets are detected and handled by the grid, but the interface is needed for this to happen
*
* @param {array} _attrs array to add further attributes to
*/
getDetachedAttributes: function(_attrs) {
},
@ -895,6 +904,28 @@ var et2_grid = et2_DOMWidget.extend([et2_IDetachedDOM, et2_IAligned],
},
setDetachedAttributes: function(_nodes, _values) {
},
/**
* Generates nextmatch column name for headers in a grid
*
* Implemented here as default implementation in et2_externsion_nextmatch
* only considers children, but grid does NOT instanciate disabled rows as children.
*
* @return {string}
*/
_getColumnName: function()
{
var ids = [];
for(var r=0; r < this.cells.length; ++r)
{
var cols = this.cells[r];
for(var c=0; c < cols.length; ++c)
{
if (cols[c].nm_id) ids.push(cols[c].nm_id);
}
}
return ids.join('_');
}
});
et2_register_widget(et2_grid, ["grid"]);