2 / 2
May 2021

Dear Developers,
I would like to access the etemplate objects of the opened Framework (edit) tabs of my application, like I can do with the popups_get function for the popups:

 	/**
 	 *
 	 * Call apply filters in nextmatch widgets of all opened popups.
 	 *
 	 * @param app_name
 	 * @param regex_string
 	 * @param nm_name
 	 * @constructor
 	 */
 	UpdateNMinpopups(app_name, regex_string, nm_name){
 		var that = window;
 
 		var popups = that.framework.popups_get(app_name, regex_string);
 
 		//console.log(popups);
 		//console.log( popups.length);
 
 		for (var i = 0, n = popups.length; i < n; ++i) {
 			if ( typeof popups[i]  !== 'undefined' ) {
 				let et2 = popups[i].etemplate2.getByApplication(app_name);
 				let nm = et2[0]?.widgetContainer.getDOMWidgetById( nm_name );
 				console.log(typeof nm)
 				if(!nm)
 				{
 					//console.log('no nextmatch found...');
 					return;
 				}
 				nm.applyFilters();
 				//nm.refresh(pushData.id, pushData.type);
 			}
 
 		}
 	}

I read here


that I can set an local reference in et2_ready(), but when I try to access it in my app.ts push function it is undefined…

I tried also to call get the object via

etemplate2.getByTemplate(‘acactivity2.header.edit’)

but I get no widgetcontainer in the result…

I also tried accessing the tabs via the Ids. But because the ids are in the form acactivity2-MQii-egw_fw_ui_tab_header and I dont know how the -MQii- part is build I had also no success.

I pretty sure I am missing something essential here and I would appreciate your support!
Thank you and best regards,
Alex

  • created

    May '21
  • last reply

    May '21
  • 1

    reply

  • 819

    views

  • 2

    users

  • 1

    link

Hi Alexander,

not sure I understand your problem correct.

Some general information, which might be helpful:

  • main application tabs instanciate their app.js object under global app[appname], but that is obviously not possible, if an app opens more then one tab, at the tabs would overwrite their app.js object (mainly the state / local variables)
    • to cope with that situation we introduces private app.js objects, basically a closure with an app object, instead using the global app object
    • you can always access the correct app-object (either global or private) from an etemplate2 object via it’s app_object property
  • similar problem exists with multiple eTemplate objects or opening a dialog, the et2 property of an app.js object can obviously only point to one eTemplate objects
    • you can use the static method etemplate2.getByTemplate()
    • an other way is for event handlers to use the widget closure or parameter of the handler and then use widget.getInstanceManager() to get the etemplate2 object instead this.et2
  • for a server-side push message or JSON response you will always end up in the global app[appname] app.js (since 21.1 this will even be loaded on demand from the server), so it’s this.et2 might be unset or worse not the etemplate2 widget-container you expect to talk to
    • such a handler has to search the correct etemplate2 object and/or app.js object (see above)

Hope that makes helps to understand the situation better.

Ralf