ext 集成的相关总结一
1:tab布局及控件显示与隐藏
vaf field=Ext.getCmp("").getEl().dom《Ext的原型》
function disableField(field)
{field.disable();}
function enableField(field)
{field.enable();}
2:grid数据的渲染:
renderer属性:
a:function rendererHstflg(v)
{
switch(v){
case '1':
return "是";
case '0':
return "否";
}
}
b:function hyperlink(v){
return "<a href='#' onClick='openModifyWindow()'>" + v + "</a>";
}
3:页面及数据的列表
window: window.location.href="";
iframe: iframe.src="";
form: url="";
grid: dataurl="";
reftree: fieldLabel="发布机构" textValue="" textId="00000000000"
dataUrl="${pageContext.request.contextPath" hiddenMode="value"
allowBlank="false" rootVisible="true" rootText="中国" rootValue="00000000000" selModel="multiple"
tree: rootVisible="false" anchor="100%"
deep="1" dataUrl="">
tree.node: text="业务分类" id="NOSUPCOD" leaf="false" attributes='"clstyp":"","sbjcod":""'
4:获取数据及组织数据:
var grid = Ext.getCmp("newgrid");
var sel = grid.getSelectionModel().getSelections();
var record = Ext.getCmp("").getSelectionModel().getSelected();
var anlcod =record.get('anlcod').trim();
var store = Ext.getCmp("newgrid").getStore();
var index = store.indexOf(record);
var count= store.getCount();
store.insert(index + 1, record);
store.remove(record);
Ext.each(records,function(record,index,records){);
Ext.getCmp('grididx').store.each(function(record) {}//简易
tree.root.reload();
tree.root.expand(true, false);
nodemenu.showAt(event.getXY()); //取得鼠标点击坐标,展示菜单
5:提交数据:
Ext.getCmp('searchform').getForm().submit({
url :""+parames,
method :"POST",
success : function(form, action) {
Ext.getBody().unmask();
Ext.ptx.SlideMsg.msg("信息提示", action.result.msg);
},
failure : function(form, action) {
Ext.getBody().unmask();
if(action.failureType == 'client'){
Ext.MessageBox.alert("错误提示", "提交信息错误!");
}
}
});
6:
a:异步获取数据:
Ext.Ajax.request({
url: '',
params : del,
success: function(response,options) {
Ext.getBody().unmask();
Ext.getCmp('').store.reload();
var obj = Ext.util.JSON.decode(response.responseText);
Ext.ptx.SlideMsg.msg("信息提示", obj.msg);},
failure: function(response,request) {
Ext.getBody().unmask();
Ext.MessageBox.alert( "删除时出现异常", response.responseText );
}});
其中:::数据的封装:
var del = {};
var columns = ['sbjcod','anlcod','cfgbsl'];
if (columns.length>0) {
for (var i=0;i<columns.length;i++) {
var x = [];
for (var m=0;m<sel.length;m++) {
x.push(sel[m].get(columns[i]));
}
del[columns[i]] = x;
}
b:另一种方式
Ext.Ajax.request( {
url :"",
method :"POST",
success : function(response, options) {
Ext.getBody().unmask();
var arrayproperty=response.responseText;
var array=arrayproperty.split("&&");
var arrayObj=[];
var select=document.getElementById("D1");
for(var i=0;i<array.length;i++){
var obj=Ext.util.JSON.decode(array[i]);
var option= new Option(obj.colnam,obj.colcod);
select.options.add(option);
}
},
failure : function(response, options) {
Ext.getBody().unmask();
var obj = Ext.util.JSON.decode(response.responseText);
Ext.MessageBox.alert("错误提示", obj.msg);
},
params : {
'anlStrDfnBGVO.sbjcod' : sbjcod ,
'anlStrDfnBGVO.anlcod' : anlcod,
'anlStrDfnBGVO.cfgbsl':cfgbsl
}
});
-----------------------
其他形式:
Ext.Ajax.request({
url :'${pageContext.request.contextPath}/*.action?'+urlParames,
success: function(response,options) {},
failure: function(response,request) {}});
-----------------------
Ext.Ajax.request({
url: 'AdhocSortAdminBGAction_doDeleteMenuOfCascade.action',
params :{id : node.id, dattyp:dattyp},
success: function(response,options) {},
failure: function(response,request) {}});
------------------------
7:显示格式:
等待:Ext.getBody().mask("正在提交建表数据.请稍等...","x-mask-loading");
自动:Ext.ptx.SlideMsg.msg("信息提示", action.result.msg);
手动:Ext.MessageBox.alert("错误提示", "提交信息错误!");
富窗口:Ext.MessageBox.confirm('title,'content',function(btn){
if (btn=='yes') {}else{}
8:
9:模式对象:用于传递参数:(前台的数据随意获取,供后台使用)
jsp:
function js*VO( rptcod, dimcod,cfgbsl, datval, datnam) {
this.rptcod = rptcod;
this.dimcod = dimcod;
this.cfgbsl = cfgbsl;
this.datval = datval;
this.datnam = datnam;
}
var array*VO = [];
Ext.each(records,function(record,index,records){
array*VO.push(new js*VO());});
var content=Ext.encode(array*VO);
java:
JSONObject jsonObject = null;
Object pojoObject = null;
*VO *Object = null;
JSONArray jsonArray = JSONArray.fromObject(this.json*VO);
for (int i = 0; i < jsonArray.size(); i++) {
jsonObject = jsonArray.getJSONObject(i);
pojoObject = JSONObject.toBean(jsonObject, *VO.class);
*Object = (*VO) pojoObject;
list.add(*Object);
}
10:封装对象页面传值
var TopicRecord = Ext.data.Record.create(['colcod','colnam']);
var ifind = Ext.getCmp("newgrid").store.find("colcod", new RegExp("^"+record.get("colcod")+"$","i"));
if (ifind==-1) {
var myNewRecord = new TopicRecord({
colcod : colcod,
colnam : colnam
});
Ext.getCmp("newgrid").store.add(myNewRecord);
}