// the columns array, then force a page refresh
grid.columnsProvider.columns.splice(srcIdx, 1);
grid.columnsProvider.columns.splice(targetIdx, 0, srcCol);
- console.log(JSON.stringify(grid.columnsProvider.columns,'',2));
$scope.$apply();
}
flex : '@', // optional; default flex width
dateformat : '@', // optional: passed down to egGridValueFilter
+ // if a field is part of an IDL object, but we are unable to
+ // determine the class, because it's nested within a hash
+ // (i.e. we can't navigate directly to the object via the IDL),
+ // idlClass lets us specify the class. This is particularly
+ // useful for nested wildcard fields.
+ parentIdlClass : '@',
+
// optional: for non-IDL columns, specifying a datatype
// lets the caller control which display filter is used.
// datatype should match the standard IDL datatypes.
cols.expandPath = function(colSpec) {
var dotpath = colSpec.path.replace(/\.\*$/,'');
- var class_obj = egCore.idl.classes[cols.idlClass];
- var path_parts = dotpath.split(/\./);
-
- // find the IDL class definition for the last element in the
- // path before the .*
var class_obj;
- for (var path_idx in path_parts) {
- var part = path_parts[path_idx];
- var idl_field = class_obj.field_map[part];
- // unless we're at the end of the list, this field should
- // link to another class.
- if (idl_field && idl_field['class'] && (
- idl_field.datatype == 'link' ||
- idl_field.datatype == 'org_unit')) {
- class_obj = egCore.idl.classes[idl_field['class']];
- } else {
- if (path_idx < (path_parts.length - 1)) {
- // we ran out of classes to hop through before
- // we ran out of path components
- console.error("egGrid: invalid IDL path: " + path);
+ if (colSpec.parentIdlClass) {
+ class_obj = egCore.idl.classes[colSpec.parentIdlClass];
+
+ } else {
+
+ class_obj = egCore.idl.classes[cols.idlClass];
+ if (!class_obj) return;
+
+ var path_parts = dotpath.split(/\./);
+
+ // find the IDL class definition for the last element in the
+ // path before the .*
+ var class_obj;
+ for (var path_idx in path_parts) {
+ var part = path_parts[path_idx];
+ var idl_field = class_obj.field_map[part];
+
+ // unless we're at the end of the list, this field should
+ // link to another class.
+ if (idl_field && idl_field['class'] && (
+ idl_field.datatype == 'link' ||
+ idl_field.datatype == 'org_unit')) {
+ class_obj = egCore.idl.classes[idl_field['class']];
+ } else {
+ if (path_idx < (path_parts.length - 1)) {
+ // we ran out of classes to hop through before
+ // we ran out of path components
+ console.error("egGrid: invalid IDL path: " + path);
+ }
}
}
}
var col = cols.cloneFromScope(colSpec);
col.path = dotpath + '.' + field.name;
- cols.add(col, null, true);
+ cols.add(col, false, true,
+ {idl_field : field, idl_class : class_obj});
});
} else {
nonsortable : colSpec.nonsortable,
multisortable : colSpec.multisortable,
nonmultisortable : colSpec.nonmultisortable,
- dateformat : colSpec.dateformat
+ dateformat : colSpec.dateformat,
+ parentIdlClass : colSpec.parentIdlClass
};
}
// Add a column to the columns collection.
// Columns may come from a slim eg-columns-field or
// directly from the IDL.
- cols.add = function(colSpec, fromIDL, fromExpand) {
+ cols.add = function(colSpec, fromIDL, fromExpand, idl_info) {
// First added column with the specified path takes precedence.
// This allows for specific definitions followed by wildcard
if (column.visible)
cols.stockVisible.push(column.name);
- if (fromIDL) return;
- if (!cols.idlClass) return; // ad-hoc object
+ if (fromIDL) return; // directly from egIDL. nothing left to do.
// lookup the matching IDL field
- var idl_info = cols.idlFieldFromPath(column.path);
+ if (!idl_info && cols.idlClass)
+ idl_info = cols.idlFieldFromPath(column.path);
if (!idl_info) {
// column is not represented within the IDL
column.label = idl_info.idl_field.label || column.name;
/*
// append class label to column label to better differentiate
- // columsn in the selector.
+ // columns in the selector.
// Disabled for now, since it results in columns w/ really
// long names, making the grid unappealing when any of
// these colmns are selected.