}
function fieldToColumn(fieldExpr, defaults) {
var info = parseExpr(fieldExpr),
- field = _.findWhere(info.args, {type: 'field'}) || {},
+ field = (_.findWhere(info.args, {type: 'field'}) || {}).field || {},
values = _.merge({
type: 'field',
key: info.alias,
values.label = getDefaultLabel(fieldExpr);
}
if (defaults.sortable) {
- values.sortable = field.type === 'Field';
+ values.sortable = field.type && field.type !== 'Pseudo';
}
return values;
}
return !col.image && !col.rewrite && !col.link && !info.fn && info.args[0] && info.args[0].field && !info.args[0].field.readonly;
};
+ this.canBeSortable = function(col) {
+ var expr = ctrl.getExprFromSelect(col.key),
+ info = searchMeta.parseExpr(expr),
+ arg = (_.findWhere(info.args, {type: 'field'}) || {});
+ return arg.field && arg.field.type !== 'Pseudo';
+ };
+
// Aggregate functions (COUNT, AVG, MAX) cannot display as links, except for GROUP_CONCAT
// which gets special treatment in APIv4 to convert it to an array.
this.canBeLink = function(col) {
<option value="text-right">{{:: ts('Right') }}</option>
</select>
</div>
+ <div class="form-inline" ng-if=":: $ctrl.parent.canBeSortable(col)">
+ <label title="{{:: ts('Allow user to click on header to sort table by this column') }}">
+ <input type="checkbox" ng-checked="col.sortable !== false" ng-click="col.sortable = col.sortable === false" >
+ {{:: ts('Sortable Header') }}
+ </label>
+ </div>
<div ng-include="'~/crmSearchAdmin/displays/colType/' + col.type + '.html'"></div>
</fieldset>
</div>