How to create two more tabs from the grid

Usually, we create a grid list and linked with a form. when we click the “pencil” image before the record, the grid can create a new tab for form application but only one tab. If I open another record, the previous page will be replaced.

How to create two or more tabs for the same form application?
Because we need to compare different records at the same time. (When the user clicks the “pencil” button in the grid, the system opens a new tab, when the user clicks another “pencil", system will create a new tab for another record.)

ok not tested but this is how I think you would do it.
The pencil edit link was created using the Application links.
Edit that edit Application Link and go to Properties.
Select Open in anther window. and down below you will see the option to open it in a Menu Tab.
Good luck

Thank you for your reply! I tried this way before, but open one tap only, If you click another edit pencil button, the old tab will be replaced by new one.
I also tried press shift or ctrl same time. it doesnt work too.

Hi, if you mean a tab in a menu with tabs, well I think there isn’t a standard way via SC to do that, because every tab has a “name” and so when you click “open myform with id=6 on tab myform”, system will open a tab myform and if it exists, replace the page inside it.
One way, not standard, is to create a field and you can put there an image and when you click on it a javascript function is called, that function is a js function of the menu, and you can simulate the new tab creation but chenging parameters you can tell “open myform with id=6 on tab myform_6”, so every record will have a new tab.

hi Vincenzo,
Thank you for your reply, your suggestion sounds resonable, because I am not good at javascript. Could you write a small sample to show me how to do it.
Very appriciate. :smiley:
Jonathan.

Ok, let’s try…

in the grid OnScriptInit event insert:

?>

<script type="text/javascript" >
function openmyform( myid )
{
	var func_menu_aba = null;
	var padre = null; 
	
	padre = window.top;
	if ( padre ) {
		eval ("func_menu_aba = padre.createIframe");
	}	
	
	if ( typeof func_menu_aba === 'function' ) {
		
        func_menu_aba('myform_'+myid, 'Title', '', '','', '../myform?id='+myid , 'form');
 				
	} else {
		window.open( '../myform?id='+myid );	
	}
	
}
	
</script>

<?PHP

then let’s say we use a custom field {pencil} with the link to open the form

{pencil} = "<a href=\"javascript:openmyform('{id}');\" class=\"scGridFieldOddLink\" >Edit</a>";

now it’s just a text Edit, if you want an image replace Edit with the html tag img.

This should work.

Bye

3 Likes

hi Vincenzo,
Thank you for your help very much. It works well. I am very happy. :blush:
One more thing, the “Exit” button on the form page doesn’t work now. When I click ‘Exit’, the form report message " Invalid data".
I am tried to add a new “close” button with javascript “window.close()”. but it doesn’t work. Could you help me to perfect this function? Thank you very very much.
Jonathan

What if you hide the Exit button from the Toolbar, then made your own Link button and added THAT to the toolbar instead.

hi nwdbs,
Thank you for your suggestion. what is THAT?
I did add a button with javascript “window.close();” but it doesn’t work.
Jonathan.

Well, you can hide the EXIT button in the FORM and let the user use the X in the tab to close it, otherwise, you could create a custom EXIT BUTTON, that calls a javascript that is almost the same the code to create the TAB, but instead of padre.createIframe you have to use padre.del_aba_td and that function has only one parameter, ‘myform_’+myid.

not tested :stuck_out_tongue_winking_eye:

hi Vincenzo,
I customize an Exit button, it works as you said. :+1: :+1:
But finally, I select to hide the exit button in the form and let user use the X in the tab. This is a safe way. Because the button will not work well if the form opened in another way.
Thanks again. I should treat you dinner. :joy:
Jonathan.

:plate_with_cutlery: :+1: tell me the city and if I’ll pass I’ll accept it :smiley:

The function that creates the tab, actually look for a function in the father window (the menu) if there is a father it calls the function and create the tab, to close it, do the same, if there is the father (the menu), call che function del_aba_td, otherwise the window was opened in another way, for example with a window.open, so now you can call window.close.

hi Vincenzo,
I am in Vancouver Canada, warmly welcome you anytime. :slight_smile:
Thank you for your explanation, this will really be helpful to understand your code.
thanks again.
Jonathan

2 Likes

Excellent! It really works! Thanks a lot!

1 Like

Hello @Vincenzo !
The code you’ve created is great! It’s exactly what I was looking for! However, I’d like to be able to click the Update button and have the form close automatically (and update the previous grid), similar to the ‘Close form after update’ option in the “Application Link”. Is it possible to implement something like that?

Thank you very much!

Hi, never tried, but in the OnAfterUpdate try to call function

sc_ajax_javascript( ‘JavascriptMethodName’, array(“parameter”))

that calls a javascript function, in this function you have to call the function del_aba_td of the parent window ( the menu ) as I said in

Hi!
Sorry for the delayed response.
Yes, this method works to close the new window, but it doesn’t refresh the previous grid. Do you have any suggestions on how to do that?
Thank you very much!

Hi again!
I found a solution!
I created a similar function as the previous to close the form and added the line window.opener.location.reload() to refresh the grid, like the option in the “Application Link”

? >
< script type=“text/javascript”>
function closemyform(myid) {
var func_menu_aba = null;
var padre = null;
padre = window.top;
if (padre) {
eval(“func_menu_aba = padre.closeIframe”);
}
if (typeof func_menu_aba === ‘function’) {
// Assuming there’s a function closeIframe to close the form iframe
func_menu_aba(‘myform_’ + myid);
} else {
// If not inside an iframe, you can close the current window/tab
window.close();
window.opener.location.reload();
}
}
</ script>
<?PHP