Page 1 of 1

Hide button in Modal Pop up window

Posted: 2021-07-27 20:46
by rpierce
I have created a report based on a lesson in Udemy Courses. Is there some code that I can add to the report that will prevent the button from being visible if the user is in a modal popup window such as when they enter an existing record to edit it?

Thank you again!

Re: Hide button in Modal Pop up window

Posted: 2021-07-28 01:25
by rpierce
This may have not been clear enough. The button to print the report is included in several of my tables while in Detail View. Clicking the button prints out a report of the data. I wish to have it so that when a person is viewing previously entered data in a modal pop up of detail view, such as when editing an existing record the button odes not appear.

Re: Hide button in Modal Pop up window

Posted: 2021-07-28 06:09
by jsetzer
I'm not 100% sure but there could be a request parameter "Embedded" in standard AppGini generated DV model dialogs.

You may evaluate

Code: Select all

(!$_REQUEST['Embedded'] == 1)
before rendering the button.

Re: Hide button in Modal Pop up window

Posted: 2021-07-28 15:34
by rpierce
Hi again,

Where do I insert this code?

Re: Hide button in Modal Pop up window

Posted: 2021-07-28 18:23
by rpierce
I have this code

Code: Select all

if(isset($_REQUEST['dvprint_x'])) return;
in the hooks/table_name function table_name_dv. It determines if the window is Print Preview. Could another similar line be added to determine if it is a Modal Popup?

Re: Hide button in Modal Pop up window

Posted: 2021-07-29 04:05
by jsetzer
rpierce wrote:
2021-07-28 15:34
Where do I insert this code?
Is there some code that I can add to the report that will prevent the button from being visible
At the place you create "the button". I don't know in which file you do this.

Re: Hide button in Modal Pop up window

Posted: 2021-07-29 19:33
by rpierce
I have this code in Hooks/table_name_dv function.

Code: Select all

	function audit_dv($selectedID, $memberInfo, &$html, &$args) {
			/* if this is the print preview, don't modify the detail view */
		if(isset($_REQUEST['dvprint_x'])) return;
		ob_start(); ?>
		
		<script>
			$j(function(){
				<?php if($selectedID){ ?>
					$j('#audit_dv_action_buttons .btn-toolbar').append(
						'<div class="btn-group-vertical btn-group-lg" style="width: 100%;">' +
								'<button type="button" class="btn btn-warning btn-lg" onclick="print_report()">' +
									'<i class="glyphicon glyphicon-eye-open"></i> Print Report</button>' +
						'</div>'
					);
				<?php } ?>
			});
			
			function print_report(){
				var selectedID = '<?php echo urlencode($selectedID); ?>';
				window.location = 'hooks/audit_rpt_print.php?audit_id=' + selectedID;
			}
			
			
		</script>
		
		<?php
		$form_code = ob_get_contents();
		ob_end_clean();
		
		$html .= $form_code;
	}

Re: Hide button in Modal Pop up window

Posted: 2021-08-16 16:08
by rpierce
Hi again,

I'm stumped. I got some advice from Ahmed and have been experimenting with it and the similar code you provided. I have been able to remove all the buttons on the page in question, but they are removed weather the page is modal or not. If I leave the .val()) with no value, nothing happens. If I set it as .val(1)) -- then the buttons are removed in both modal and normal mode. I have placed the code into the hooks/firstaid.php file in the firstaid_dv function and also in the header and footer extras files with the same results.

Code: Select all

			$j(function() {
				if($j('[firstaid_dv ="Embedded"]').val())
				$j('#firstaid_dv_action_buttons .btn-toolbar').remove();
});
If there is anything I can tell you to help me solve how to remove a button or group of buttons while in MODAL view. Please let me know.

Thanks for any additional assistance...

Ray