Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Datatables RowAction Create/Edit Dropdown "visible" #5009


User avatar
0
cyklussoftware created

I am using ASP.NET Core + jQuery v5.3

The following is a snippet from the Index.js of my GeneralEvent entity (generated by RAD Tool). The snippet is part of the DataTable() function. Specifically the "items" of the "rowAction" of the "columnDefs".

items: [
	{
		text: app.localize('View'),
		action: function (data) {
			_viewGeneralEventModal.open({ data: data.record });
		}
	},
	{
		text: app.localize('Edit'),
		visible: function (data) {
			var eventObject = data.record.generalEvent;

			abp.services.app.generalEvents.hasPermissionForEntity(eventObject)
				.done(function (result) {
					var hasPermission = result;
					console.log(hasPermission);
					//return result; // I would like to return this value. This obviously won't work
				});

			//return _permissions.edit; // original code
		},
		action: function (data) {
			_createOrEditModal.open({ id: data.record.generalEvent.id });
		}
	},

OK, so hopefully you know what I'm talking about now.

I am making a sort of custom permissions system that is based on OrganizationUnits. Basically, a user can only see the Create/Edit menu option in the RowAction dropdown if he has belongs to the OrganizationUnit of the Event.

I know the "visible" attribute is set using the anonymous function. How would I return a value from my app service? I know what I have above doesn't work because it's asynchronous, but it shows what I'm trying to do.

I guess my question becomes this: How would I set the "visible" property of the RowAction dropdown once my data has been calculated in my AppService?

Thanks!


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You need to include a new property to your Dto, and set it's value using generalEvents.hasPermissionForEntity method. If you can get the result of "generalEvents.hasPermissionForEntity" in your main query for getting the records of your databasle, it would be better.