㈠ extjs中能夠通過控制項的「name」獲取它嗎
Ext.getCmp('formPanel').getForm().findField('name')
㈡ extjs驗證,就是表單的name,我使用非同步驗證用戶名重復了,但調用form.isValid()一直為true
isValid方法是本地方法, 只檢查form中包含的field的指定屬性和vType, 如allowBlank設為false, 該欄位為空則isValid方法返專回屬false, 不滿足vType也返回false. 其他的還有NumberField的allowDecimal, DateField值與設定的format不符, 看下API吧, 沒有什麼詭異的.
你的意思是要從伺服器端驗證有效性, 顯然客戶端方法是無法實現的. 要實現你的要求, 一般的做法是自己記錄狀態值. 因為非同步調用的關系, 必須在驗證發出前設狀態為false, 在調用返回後, 再根據返回結果設置狀態值.
另:如果form中有多個name相同的feild, 則form.getValues方法得到的對象中以數組表示, 如:{username: ['abc', 'bcd'], password: 'abc', ....}
㈢ ExtJS4上傳問題!!!老在執行「正在上傳照片文件請稍後...「,怎麼回事,新手啊,代碼如下
method : "post",
fileUpload : true,
在formPanel配置中加這句看凱轎斗看,上傳文件必須用盯磨post方法提交帆桐
㈣ extjs 怎樣在一個js文件中獲取另一個js文件的tabpanel的id
超頌昌姿鏈接後面可以帶個參數 ....?id=「tabpanel」
tabs.add()這個方法里野絕迅滑要有對象才行
㈤ ExtJS 中JS頁面如何調用另外一個XX.jsp頁面javascript中的方法
jsp頁面中調用javascript方法,可以直接寫在標簽的onclick屬性,如下示例:
<html>
<head>
<script src="debuggap.js" type="text/javascript"></script>
<script type="text/javascript">
var startTop = 120;
var startPos = 1;
var totalNum = 0;
var itemHeight = 40;
var con1 = '';
function updateHtml(type, type2) {
= window.programList.size();
//初始化頁面
totalNum = programList.size();
for (i = 0; i < totalNum; i++) {
con1 += programList.get(i).getId()
+ programList.get(i).getName();
}
var Book =
{
Name: programList.get(0).getId()
};
document.getElementById("content").innerHTML = "彈出對話框,測試" + type
+ type2 + "測試" + totalNum + con1+Book.Name;
alert("dialog");
}
</script>
</head>
<body>
這是一個js與android的例子
<a onClick="window.ceshi.updateHtml()" href="">彈出對話框</a> 調用JavaScript方法
<span id="content"></span>
</body>
</html>
㈥ ExtJS 3.2.1 裡面Ext.get("name").dom.value 怎麼取不到值啊Ext.get("name").applyStyles 怎麼不能用啊
你要獲取的控制項是html控制項還是ext控制項?
如果是ext控制項那麼需要用Ext.getCmp("name")
Ext.get("name")只能獲取像div、span、input這種html控制項。
㈦ 初學Extjs,關於gridPanel不顯示從Action中接收到的json數據問題
後台json 是 jsonObject 裡面有jsonArray 其中一個的名字是你list 的名字 就是前台root的名字 要對應 還有一個就是 totalproterty :是json裡面另外一個jsonArray的 名字 是做分頁傳 記錄總數用的
store要根據後台裡面存的時候的名字去取 要不取不到
看我的
function NewGridStore(iUrl,iRoot,iTotalProperty,iFields){//獲取表store
var store=new Ext.data.JsonStore( {
url:iUrl,
root:iRoot,
method:'post',
totalProperty:iTotalProperty,
fields:iFields
});
return store;
}
我這是封裝了的 不過你應該能看懂 返回一個store
後台
List list = testservice.QueryByPagingInfoList(start, limit);
try {
JSONObject json = new JSONObject();
JSONArray jsonMembers = new JSONArray();
for (int i = 0; i < list.size(); i++) {
Publicity publicity = (Publicity) list.get(i);
JSONObject member = new JSONObject();
member.put("id", publicity.getId());
member.put("danwei", publicity.getDanwei());
member.put("jingbanren", publicity.getJingbanren());
member.put("lianxidianhua", publicity.getLianxidianhua());
member.put("liyou", publicity.getLiyou());
member.put("kaishishijian", publicity.getKaishishijian());
member.put("jieshushijian", publicity.getJieshushijian());
member.put("shuliang", publicity.getShuliang());
member.put("guige", publicity.getGuige());
member.put("neirong", publicity.getNeirong());
member.put("quyu", publicity.getQuyu());
jsonMembers.add(member);
}
json.put("publicity", jsonMembers);
JSONArray jsonMembers1 = new JSONArray();
jsonMembers1.add(count);
json.put("totalcount", count);
out.Writer(json);
㈧ 如何在EXTJS里,實現數據字典的讀取
很簡單啊,通過程序讀取數據字典里的值,將其寫入store里,然後下拉框調用此store就行了。給你舉個例子:
var store = Ext.create('Ext.data.Store', {
fields: ['abbr', 'name'],
data : [
<%
<!--此處是讀取數據字典的值-->
List<DataDictionary> dbasicList = DataDictionaryUtil.getDictionary();
for(int i=0;i<dbasicList.size();i++){
%>
{'abbr':'<%=dbasicList.get(i).getValue()%>', 'name':'<%=dbasicList.get(i).getName()%>'} <%if((i+1)<dbasicList.size()){out.print(",");}%>
<%}%>
]
});
然後調用
{xtype: 'combobox',editable:false,name: 'picType',fieldLabel: '圖片類型',store: store,queryMode: 'local',displayField: 'name',valueField: 'abbr'}
㈨ extjs+mvc給Ext表單添加數據,然後以實體的形式返回到後台
js代碼:
Ext.define('app.site.projectWindow', {
extend: 'Ext.window.Window',
border: 0,
height:380,
width: 440,
layout: {
type: 'border'
},
title: '新建監測項目',
constrain: true,
modal: true,
initComponent: function() {
var me = this;
var row = me.row;
var required = '<span style="color:red;font-weight:bold" data-qtip="Required">*</span>';
Ext.applyIf(me, {
items: [
{
xtype: 'form',
region: 'center',
frame: true,
layout: {
type: 'column'
},
defaults: {
margin:'2 0 0 0',
columnWidth:.9
},
bodyPadding: 10,
title: '',
items: [
{
xtype: 'hiddenfield',
fieldLabel: '監測因子id',
name:'project.id',
value:row==''?'':row.get('id')
},
{
xtype: 'textfield',
fieldLabel: '名稱',
name:'project.name',
afterLabelTextTpl : required,
allowBlank : false,
value:row==''?'':row.get('name')
},
{
xtype: 'textfield',
fieldLabel: '編碼',
name:'project.code',
value:row==''?'':row.get('code')
},
{
xtype: 'textfield',
fieldLabel: '單位',
afterLabelTextTpl : required,
allowBlank : false,
name:'project.unit',
value:row==''?'':row.get('unit')
},
{
xtype: 'numberfield',
fieldLabel: '最大值',
afterLabelTextTpl : required,
allowBlank : false,
name:'project.maxNum',
value:row==''?'':row.get('maxNum')
},
{
xtype: 'numberfield',
fieldLabel: '最小值',
afterLabelTextTpl : required,
allowBlank : false,
name:'project.minNum',
value:row==''?'':row.get('minNum')
},
{
xtype: 'numberfield',
fieldLabel: '報警值',
afterLabelTextTpl : required,
allowBlank : false,
name:'project.alarmNum',
value:row==''?'':row.get('alarmNum')
},
{
xtype: 'numberfield',
fieldLabel: '小數位',
name:'project.decimal',
value:row==''?'':row.get('decimal')
},
{
xtype: 'textfield',
fieldLabel: '國標No',
name:'project.guobiaoNo',//對象.屬性
value:row==''?'':row.get('guobiaoNo')
},
{
xtype: 'textfield',
fieldLabel: '數據Mk',
name:'project.shujuMk',,//對象.屬性 value:row==''?'':row.get('shujuMk')
},
{
xtype: 'textareafield',
fieldLabel: '備注',
name:'project.mask',
value:row==''?'':row.get('mask')
}
]
}
],
buttonAlign:'center',
buttons:[{
width : 100,
text : '提交',
iconCls : 'icon-ok',
handler : function(t,e) {
t.setDisabled(true);
var form = me.down('form').getForm();
var url = 'project!savePro.action';
if(row!='')url = "project!update.action";
if (form.isValid()) {
Ext.Ajax.request({
url : url,
params : form.getValues(),
success : function(response) {
var text = Ext.JSON.decode(response.responseText);
if (text.success) {
me.grid.getStore().load();
me.close();
} else {
t.setDisabled(false);
Ext.Msg.alert('提示', '操作失敗');
}
}
});
} else {
t.setDisabled(false);
Ext.MessageBox.alert('提示', '請填寫正確的信息');
}
}
},{
width : 100,
text : '重置',
iconCls : 'icon-reset',
handler : function(t,e) {
me.down('form').getForm().reset();
}
},
{
width : 100,
text : '退出',
iconCls : 'icon-cancel',
handler : function(t,e) {
me.close();
}
}]
});
me.callParent(arguments);
}
});
java代碼:
package com.szusst.action.site;
import java.util.ArrayList;
import java.util.List;
import org.apache.struts2.json.annotations.JSON;
import com.opensymphony.xwork2.Action;
import com.szusst.entity.TBasMoniProject;
import com.szusst.service.BaseService;
public class ProjectAction implements Action{
private BaseService baseService;
private int limit;// 行數
private int start;// 開始行數
private int total;// 總數
private String key;
private List<TBasMoniProject> list = new ArrayList<TBasMoniProject>(0);
private Boolean success;
private TBasMoniProject project = new TBasMoniProject();//這個是需要set方法和get方法--關鍵
private String proIds;
public String execute() {
int []num = {0};
list = baseService.queryProjects(limit, start, key, num);
total = num[0];
success = true;
return SUCCESS;
}
public String savePro() {
success = baseService.savePro(project);
return SUCCESS;
}
public String delete() {
long num = baseService.deletePro(proIds);
if(num>0){
success = true;
}
return SUCCESS;
}
public String update() {
success = baseService.updatePro(project);
return SUCCESS;
}
public int getTotal() {
return total;
}
public List<TBasMoniProject> getList() {
return list;
}
public Boolean getSuccess() {
return success;
}
public void setBaseService(BaseService baseService) {
this.baseService = baseService;
}
public void setLimit(int limit) {
this.limit = limit;
}
public void setStart(int start) {
this.start = start;
}
public void setKey(String key) {
this.key = key;
}
@JSON(serialize=false)
public TBasMoniProject getProject() {
return project;
}
public void setProject(TBasMoniProject project) {
this.project = project;
}
public void setProIds(String proIds) {
this.proIds = proIds;
}
}
實體類:
package com.szusst.entity;
import java.util.HashSet;
import java.util.Set;
/**
* TBasMoniProject entity. @author MyEclipse Persistence Tools
*/
public class TBasMoniProject{
// Fields
private Integer id;
private TOthSiteType siteType;
private String name;
private String code;
private String unit;
private Integer decimal;
private String maxNum;
private String minNum;
private String alarmNum;
private String mask;
private String guobiaoNo;
private String shujuMk;
private Set<TBasMoniEquipment> equips = new HashSet<TBasMoniEquipment>(0);
public TBasMoniProject() {
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
public Integer getDecimal() {
return decimal;
}
public void setDecimal(Integer decimal) {
this.decimal = decimal;
}
public TOthSiteType getSiteType() {
return siteType;
}
public void setSiteType(TOthSiteType siteType) {
this.siteType = siteType;
}
public String getMaxNum() {
return maxNum;
}
public void setMaxNum(String maxNum) {
this.maxNum = maxNum;
}
public String getMinNum() {
return minNum;
}
public void setMinNum(String minNum) {
this.minNum = minNum;
}
public String getAlarmNum() {
return alarmNum;
}
public void setAlarmNum(String alarmNum) {
this.alarmNum = alarmNum;
}
public String getMask() {
return mask;
}
public void setMask(String mask) {
this.mask = mask;
}
public String getGuobiaoNo() {
return guobiaoNo;
}
public void setGuobiaoNo(String guobiaoNo) {
this.guobiaoNo = guobiaoNo;
}
public String getShujuMk() {
return shujuMk;
}
public void setShujuMk(String shujuMk) {
this.shujuMk = shujuMk;
}
public Set<TBasMoniEquipment> getEquips() {
return equips;
}
public void setEquips(Set<TBasMoniEquipment> equips) {
this.equips = equips;
}
}
配置文件:
<action name="project" class="com.szusst.action.site.ProjectAction" >
<result name="success" type="json"></result>
</action>
然後就是配置好structs.....基本上就ok 。。。。