View Full Version : Add individual tab code outside main .js - without MVC

11 Jan 2014, 8:23 AM
I have a project I've been working on that started out as an entirely dynamic adhoc system. Reports/files were listed in a west nav pane and would add tabs to the center. Each tab contained a dynamic grid. All of this code is in one main.js script. I would just pass the configs to the dynamic grid and it handled any file I threw at it.

Now I'm finding that the users actually want more of a custom report per page, especially since they'll want grouping and summaries. I can't figure out how to add that to my dynamic grid, so I figure my best bet is to write a .js per report tab.

How can I keep my main.js with the basic viewport. The nav is loaded via JSON, so reports will show up when available. I need to have other report1.js, report2.js, report3.js, etc files that I can drop into my application folder and then have the main.js use them when the user clicks their report. I don't want to load all of these reports, just have them available to go.

Does that make sense? All help appreciated.

11 Jan 2014, 5:27 PM
I'm checking this post (http://www.sencha.com/forum/showthread.php?152742-How-to-Load-Dinamically-(On-Demand)-external-javascript-with-ExtJS-4&p=665805&viewfull=1#post665805) out. Looks like I can load the script. Not sure how much I'm going to muck this all up.

var url = "myfile.js";
var onload = function () {
// do something onload
var onerror = function () {
// do something onerror
var scope = this;
Ext.Loader.injectScriptElement(url, onload, onerror, scope);