Project using the MVC + ExtJs achieved, access control is based on the ActionResult in Controller, there is a page due to the different parameters you need to create two new ActionResult.
Do not ask me why is based on the page level, not the data level, I just want to say that this is a problem left over from history.
Now we face the problem, that is, two ActionResult two pages share the same Js file, and this file is ExtJs, well-known, ExtJs get Dom is to get through Ext.getCmp ( ''), then, the only original Id page now becomes not unique, the event will call chaos.
Yesterday wanted a solution for several years.
Method 1: Get Page path + Id suffix, to generate a unique ID.
Practice, that being the case.
Code is as follows: var url = window.location.href;
Get results, obtained is ExtJs framework page path, instead of the current plane path.
Method 2: When the page is loaded, automatically generated classes of Id + Id Guid suffix, to generate a unique ID.
Do not practice, it is theoretically possible.
Method 3: Use Js suffix transmission parameters, such as: LogisticsMgr / MatRequireView.aspx.js MatType = 111?
We get the 111, then each control + Id suffix, generate a unique ID.
Ways:
Ext.namespace("JsHelper"); //获得js文件后面的参数 如test.js?user=wuf created by wufei 2013-10-25 JsHelper.GetJsParamValue = function(param) { var rName = new RegExp("(\\?(.*))?$") var jss = document.getElementsByTagName('script'); for (var i = 0; i < jss.length; i++) { var j = jss[i]; if (j.src && j.src.match(rName)) { var oo = j.src.match(rName)[2]; if (oo && (t = oo.match(/([^&=]+)=([^=&]+)/g))) { for (var l = 0; l < t.length; l++) { r = t[l]; var tt = r.match(/([^&=]+)=([^=&]+)/); if (tt && tt[1] == param) return tt[2]; } } } } return ''; }
Method Invocation: var idPre = JsHelper.GetJsParamValue ( "MatType");
So far the problem is solved, the statement ID and access ID are all plus the variable on it.
Note: This program is invalid because Js loaded only once, so after opening the page for parameter is incorrect.
We hope adequate guidance solutions.
Reproduced in: https: //www.cnblogs.com/ushou/p/3387299.html