post by Music_Ed on Jan 13, 2022

Hello I really have a problem with setActionButton. Is it possible to return a (local) url and have it displayed on the (or another) popup?
I have this code:

$crud->setActionButton('Upload', 'fa fa-upload', function ($row) {
	return '/file-upload/' . $row->id;
}, false);

but I want to have ‘/fileupload’.$row->id on a popup. I also tried to use a custom gc-load.js file, and tried to do a Ajax call from there like this:

$(document).ready(function () {
	$('.gc-container').groceryCrud({
		openInModal: true,
		hashEvents: false,
		actionButtons: [{
			iconCssClass: 'fa fa-upload',
			label: 'Upload',
			onClick: function (primaryKeyValue) {
				/* This doen't work, I tried to load a Modal wrapper, but it conflicts with 
		                 Grocerycrud's own popup 
				 var m = BootstrapModalWrapperFactory.createAjaxModal({
				        message: '<div class="text-center">Loading</div>',
				        closable: true,
				        title: "Data upload",
				        closeByBackdrop: true,
				        sendId: true, // default is true which send the modal id as a url parameter.
				        size: "modal-sm",
				        ajax: {
				             url: '/file-upload/'//+primaryKeyValue
				        }
				});*/
			  }
		}],
	});	
});

I am completelely stuck here can anyone please have some help.

post by Music_Ed on Jan 14, 2022

First, sorry for the double post. I got a message that this post was blocked by the automatic spamfiler.
I’ve sorted it out by installing a simple jQuery Modal library. (Zebra Dialog) My guess is that bootstrap modals interfere with the modals by GroceryCrud. In integrated it by inserting the zebra init in the above on click function:

...
onclick: function (primaryKeyValue) {
new $.Zebra_Dialog({
    type: false, 
    custom_class: "ZebraDialog_iFrame", 
    source: {
        iframe: {
			src: "http://myserver.com/file-upload/"+primaryKeyValue
		    }
    },
	title: "Filemanagement en upload voor id:"+primaryKeyValue,
	width: 800,
	height: 800     
 });
}
...

post by sorin.sfirlogea on Jan 15, 2022

I usually do this in a very simple manner:

$crud->setActionButton('Upload', 'fa fa-upload', function ($row) {
	return 'javascript:someJSFunction(' . $row->id . ')';
}, false);

Then, in the JS function, I am able to create jQuery dialogs etc.

post by Music_Ed on Jan 15, 2022

Thanks for your reaction. Good to see that it can be easier.
I thought it wasn’t possible to inject javascript in setActionButton because grocery crud would block it so I didn’t try.

post by daveoreardon on Jan 19, 2022

post by sorin.sfirlogea on Jan 19, 2022

1 / 6
Jan 2022