Question

How to disable the List items in the Modal Box on a condition-by-condition basis

Hello Community,



On a conditional basis, I'd want to deactivate the items in the list (Look at the screenshot below). What are the best ways to do this ?

 

 

Thanks and Regards

Sarthak Jain

Like 0

Like

3 comments

Do you want to remove these roles from the system or hide them for certain lookup?

Hello Vladimir,



I want to hide these roles for certain lookup on conditional basis.



Many Thanks!

Hello Sarthak,

 

You need to create a custom filtration for the column as described here or here. But as for the section, it's not an easy task. You will need to override base methods in your section schema and add filter groups in case some column is used for the filtration:

/**
			 * @inheritdoc Terrasoft.BaseViewModel#onLookupDataLoaded
			 * @override
			 */
			onLookupDataLoaded: function(config) {
				this.callParent(arguments);
				this.mixins.LookupQuickAddMixin.onLookupDataLoaded.call(this, config);
			},
			getLookupListConfig: function() {
				return this.mixins.LookupQuickAddMixin.getLookupListConfig.apply(this, arguments);
			},
 
			/**
			 * @inheritdoc Terrasoft.BaseViewModel#getLookupQuery
			 * @override
			 */
			getLookupQuery: function(filterValue, columnName) {
				var esq = this.callParent(arguments);
				this.applyColumnsOrderToLookupQuery(esq, columnName);
				var filterGroup = this.getLookupQueryFilters(columnName);
				esq.filters.addItem(filterGroup);
				return esq;
			},
			/**
			 * Applies order information to lookup entity schema query.
			 * @protected
			 * @param {Terrasoft.EntitySchemaQuery} esq Entity schema query.
			 * @param {String} columnName Lookup column name.
			 */
			applyColumnsOrderToLookupQuery: function(esq, columnName) {
				var lookupColumn = this.getColumnByName(columnName);
				var lookupListConfig = lookupColumn.lookupListConfig;
				if (!lookupListConfig || !lookupListConfig.orders) {
					return;
				}
				var columns = esq.columns;
				this.Terrasoft.each(lookupListConfig.orders, function(order) {
					var orderColumnPath = order.columnPath;
					if (!columns.contains(orderColumnPath)) {
						esq.addColumn(orderColumnPath);
					}
					var sortedColumn = columns.get(orderColumnPath);
					var direction = order.direction;
					sortedColumn.orderDirection = direction ? direction : Terrasoft.OrderDirection.ASC;
					var position = order.position;
					sortedColumn.orderPosition = position ? position : 1;
					this.shiftColumnsOrderPosition(columns, sortedColumn);
				}, this);
			},
			/**
			 * Shift columns order position.
			 * @private
			 * @param {Array} columns Entity columns.
			 * @param {Object} sortedColumn Entity sorting column.
			 */
			shiftColumnsOrderPosition: function(columns, sortedColumn) {
				var sortedColumnOrderPosition = sortedColumn.orderPosition;
				if (Ext.isNumber(sortedColumnOrderPosition)) {
					columns.each(function(column) {
						if (column !== sortedColumn && Ext.isNumber(column.orderPosition) &&
							column.orderPosition >= sortedColumnOrderPosition) {
							column.orderPosition += 1;
						}
					});
				}
			},

So I guess it would be easier to enable record permissions for the object that is used in your lookup and setup them for roles. Then specific roles will see a specific set of records in the popup.

 

Best regards,

Oscar

Show all comments