Page 1 of 1

enable adding to lookup in modal window

Posted: 2021-03-02 13:29
by onoehring
Hi,

I notice, that when I open a table the usual way, I (depending on permissions) am able to add to lookup fields directly.
e_reg.png
e_reg.png (6.49 KiB) Viewed 4018 times
Unfortunately this is does not seem to be possible when the same table is opened from a child-register in a modal window:
e_mod.png
e_mod.png (10.89 KiB) Viewed 4018 times
My request: Please add the option to add to lookup fields directly from modal windows as well.
Olaf

Re: enable adding to lookup in modal window

Posted: 2021-03-05 15:14
by zibrahim
Hi Olaf,
I believe similar issue was discussed in this post
viewtopic.php?t=3502
I am using pböttcher's suggested codes and it works well.
However, I need to keep changing it whenever I generate the AG files.
I hope this will help.

Stay safe.

Re: enable adding to lookup in modal window

Posted: 2021-03-06 08:55
by onoehring
Hi zibrahim,

sure this helps. Thank you for pointing out the thread.

For my purpose I installed a new button below the child table - maybe someone else can make use of it (this solution will stay when you regenerate your application, but is's a little different approach than zibrahim's link shows):
child_new_btn.png
child_new_btn.png (5.32 KiB) Viewed 3945 times
The code I used was this the following. .. May be easier, but it works (I am no JS type of person). I placed it into the footer and adding the variable which holds all code to DV and TVDV footer:

Code: Select all

// START button
	$customerhint = '<button type="button" class="btn btn-success hspacer-md" id="SOME_ID" title="SOME_TITLE"><i class="glyphicon glyphicon-plus-sign"></i> New WHATEVER</button>';	
	$customerhint = '<span class="customerhint">' . $customerhint . '</span>';		
	
	//show only once in footer below details table
	$customerhint_kurz = "\n<script>\n
	\$j(function() {
		var k_cnter = 0;
		var custxt = setInterval(custHint, 1000); 
		
		function custHint (){		
			var n = \$j('#panel_CHILDTABLENAME-PRIMARYKEYNAME').find('span.customerhint').length;	//place outside of table to show count-badge
			
			if (n < 1 ) {
				//\$j('#panel_CHILDTABLENAME-PRIMARYKEYNAME tfoot tr td').append(' " . $customerhint . "')
				\$j('#panel_CHILDTABLENAME-PRIMARYKEYNAME').append(' " . $customerhint . "');	//place outside of table to show count-badge

				\$j('.customerhint').click(function(){
					var link = '/AGTABLENAME_TO_ADD_NEW_RECORD.php?addNew_x=1&Embedded=1';
					modal_window({
					  url: link,
					   size: 'full',
					   noAnimation: true,
					   title: 'TITLE SHOWN IN MODAL WINDOW HEADER', /* change that to the desired modal window title */
					   close: function() {
						  //do things on close of modal;
					   }
					});
				
			   });

			} else {
				k_cnter++;
				if (k_cnter > 20){
					clearInterval(custHint);
				}
			}		
		};
	})
	\n</script>\n";

	// show extra button only if current user has permissions to add to the table
	$usr_has_permission = getTablePermissions('AGTABLENAME_TO_ADD_NEW_RECORD');
	if ($usr_has_permission['insert'] != 1) {
		$customerhint_kurz = '';
	}
	// END button
In the switch of the footer function I am using this to add the code:

Code: Select all

...		
		case 'detailview':
			$footer =  $customerhint_kurz. '<%%FOOTER%%>';
		break;
		
		case 'tableview+detailview':
			$footer =  $customerhint_kurz . '<%%FOOTER%%>';
		break;
...
Olaf