Extjs 4 小记

////////////////////////////////////---Ajax 等待提示消息---///////////////////////////////////////////////
var myMask = new Ext.LoadMask(Ext.getBody(),{msg:"请稍等,正在导入..."});
myMask.show();
Ext.Ajax.request({ url:"uploadAction",
 method:"POST",
params:{
 id:id
},
success:function(){
if (myMask != undefined){ myMask.hide();}
Ext.Msg.alert("消息","文件导入成功!");
 },
failure:function(){
if (myMask != undefined){ myMask.hide();}
 Ext.Msg.alert("消息","文件导入失败!");
}
});
////////////////////////////////////---动态添加元素---///////////////////////////////////////////////

var l = Ext.getCmp('_picForm').items.length;
l++;
Ext.getCmp('_picForm').add([
{ id: '_addPic' + l,
name: '_addPic' + l,
labelWidth: 60,
xtype: 'filefield',
buttonText: '选择',
fieldLabel: '图片' + l
}
]);

////////////////////////////////////---遍历元素---///////////////////////////////////////////////

 BookPanel.items.each(function(item,index,length){                           
                           alert(item.getName());
                           alert(item.initialConfig.name);
                           alert(item.initialConfig.id);
                           alert(item.initialConfig.emptyText);
                           alert(item.getValue());
                           alert(item.getXType());
  });

 ////////////////////////////////////---获取 file 原始地址---///////////////////////////////////////////////

var url = getPath(document.getElementByIdx_x("url"))

function getPath(obj) {
 if (obj) {
  if (window.navigator.userAgent.indexOf("MSIE") >= 1) {
   obj.select();
   return document.selection.createRange().text;
  } else if (window.navigator.userAgent.indexOf("Firefox") >= 1) {
   if (obj.files) {
    return obj.files.item(0).getAsDataURL();
   }
   return obj.value;
  }
  return obj.value;
 }
}

 ////////////////////////////////////---EXTJS htmlEditor ? 问号问题---///////////////////////////////////////////////

xtype: 'htmleditor',
id: 'P_DETAIL',
name: 'P_DETAIL',
fieldLabel: '详细介绍',
labelWidth: 80,
770,
height: 350,
value:'<br>',
plugins: [
Ext.create('Ext.ux.form.plugin.HtmlEditor', {
enableAll: false
})]

 ////////////////////////////////////---EXTJS 二级关联 修改store ---///////////////////////////////////////////////

在点击二级下拉列表的时候 获取一级列表数据,并删除store 数据 重新插入数据。

listeners: {

change: function (t,newV,oldV,ep)
{},

click: {
element: 'el',
fn: function () {
var newV = Ext.getCmp('PROVINCE').getValue();
if (newV == "请选择")
return;
Ext.getCmp('CITY').store.removeAll();
var a = getCityName(newV);
for (var i = 0; i < a.length; i++) {
Ext.getCmp('CITY').store.insert(i, { name: a[i] });
}
}}
}

原文地址:https://www.cnblogs.com/90nice/p/3867282.html