ext js如何动态更改xtype_Ext JS 如何动态加载JavaScript创建窗体

Dynamically generate forms from server javascript

//load *.js file from server

functionloadScript(url, callback) {varscript=document.createElement("script")

script.type= "text/javascript";if(script.readyState) {//IE

script.onreadystatechange= function() {if(script.readyState== "loaded" ||script.readyState== "complete") {

script.onreadystatechange= null;

callback();

}

};

}else{//Others

script.οnlοad= function() {

callback();

};

}

script.src=url;

document.getElementsByTagName("head")[0].appendChild(script);

}//load js text from server

functionloadScriptSrc(js, callback) {varscript=document.createElement("script")

script.type= "text/javascript";//script.async = true;

if(script.readyState) {//IE

script.onreadystatechange= function() {if(script.readyState== "loaded" ||script.readyState== "complete") {

script.onreadystatechange= null;

callback();

}

};

}else{//Others

script.οnlοad= function() {

callback();

};

}

script.text=js;

console.log(script);

document.getElementsByTagName("head")[0].appendChild(script);//不能少

callback();

}//Ext JS 6

Ext.onReady(function() {//https://www.sencha.com/forum/showthread.php?268193-How-to-load-content-dynamically-for-tabpanel

varpmain=Ext.widget('panel', {

renderTo: document.body,

height:800,

width:800,

layout:'border',

items: [{

title:'West',

region:'west',

width:200,

collapsible:true}, {

xtype:'tabpanel',

region:'center',

items: [{

title:'First Tab',

itemId:'tab01',

}, {

title:'Second Tab',

layout:'fit',

loader: {

url:'Form.json',

autoLoad:true,

renderer:'component'}

}]

}]

});//ajax config

varreqConfig={

url:'../Services/GetJSUI.ashx',

method:'get',

callback:function(options, success, response) {//var msg = ['success:', success, '\n', 'data:', response.responseText];

//alert(msg.join(''));

loadScriptSrc(response.responseText,function() {

Ext.Msg.alert("loaded js","从服务器加载JS完成");vargp=Ext.create("gpView");

Ext.ComponentQuery.query('#tab01')[0].add(gp);

});

}

};

Ext.Ajax.request(reqConfig);//loadScript("dynamicLoadJS2.js", function() {

//Ext.Msg.alert("loaded");

//var gp = Ext.create("gpView");

console.log(gp);

gp.body.renderTo(pmain);

Ext.ComponentQuery.query('#tab01')[0].add({

html: 'Oh, Hello.'

});

//Ext.ComponentQuery.query('#tab01')[0].add(gp);

//});

});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值