大致是这样,首先将该集合转化为Extdatastore,当然也可以是jsonstore或者datastore,SimpleStore,看你的集合数据是json还是数组了。然后把这个store传给combobox,指定combobox的displayField和valueField 比如这样var data = [['guestid','idvalue'],
['agentid',idvalue]]; var ds = new ExtdataSimpleStore({
fields: [id, value],
data:data
}); var cb= new ExtformComboBox({
store: ds,
displayField:"id",
valueField:"value"
});
js代码:
Extdefine('appsiteprojectWindow', {
extend: 'ExtwindowWindow',
border: 0,
height:380,
width: 440,
layout: {
type: 'border'
},
title: '新建监测项目',
constrain: true,
modal: true,
initComponent: function() {
var me = this;
var row = merow;
var required = '<span style="color:red;font-weight:bold" data-qtip="Required"></span>';
ExtapplyIf(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:'projectid',
value:row=='''':rowget('id')
},
{
xtype: 'textfield',
fieldLabel: '名称',
name:'projectname',
afterLabelTextTpl : required,
allowBlank : false,
value:row=='''':rowget('name')
},
{
xtype: 'textfield',
fieldLabel: '编码',
name:'projectcode',
value:row=='''':rowget('code')
},
{
xtype: 'textfield',
fieldLabel: '单位',
afterLabelTextTpl : required,
allowBlank : false,
name:'projectunit',
value:row=='''':rowget('unit')
},
{
xtype: 'numberfield',
fieldLabel: '最大值',
afterLabelTextTpl : required,
allowBlank : false,
name:'projectmaxNum',
value:row=='''':rowget('maxNum')
},
{
xtype: 'numberfield',
fieldLabel: '最小值',
afterLabelTextTpl : required,
allowBlank : false,
name:'projectminNum',
value:row=='''':rowget('minNum')
},
{
xtype: 'numberfield',
fieldLabel: '报警值',
afterLabelTextTpl : required,
allowBlank : false,
name:'projectalarmNum',
value:row=='''':rowget('alarmNum')
},
{
xtype: 'numberfield',
fieldLabel: '小数位',
name:'projectdecimal',
value:row=='''':rowget('decimal')
},
{
xtype: 'textfield',
fieldLabel: '国标No',
name:'projectguobiaoNo',//对象属性
value:row=='''':rowget('guobiaoNo')
},
{
xtype: 'textfield',
fieldLabel: '数据Mk',
name:'projectshujuMk',,//对象属性 value:row=='''':rowget('shujuMk')
},
{
xtype: 'textareafield',
fieldLabel: '备注',
name:'projectmask',
value:row=='''':rowget('mask')
}
]
}
],
buttonAlign:'center',
buttons:[{
width : 100,
text : '提交',
iconCls : 'icon-ok',
handler : function(t,e) {
tsetDisabled(true);
var form = medown('form')getForm();
var url = 'project!saveProaction';
if(row!='')url = "project!updateaction";
if (formisValid()) {
ExtAjaxrequest({
url : url,
params : formgetValues(),
success : function(response) {
var text = ExtJSONdecode(responseresponseText);
if (textsuccess) {
megridgetStore()load();
meclose();
} else {
tsetDisabled(false);
ExtMsgalert('提示', ' *** 作失败');
}
}
});
} else {
tsetDisabled(false);
ExtMessageBoxalert('提示', '请填写正确的信息');
}
}
},{
width : 100,
text : '重置',
iconCls : 'icon-reset',
handler : function(t,e) {
medown('form')getForm()reset();
}
},
{
width : 100,
text : '退出',
iconCls : 'icon-cancel',
handler : function(t,e) {
meclose();
}
}]
});
mecallParent(arguments);
}
});
java代码:
package comszusstactionsite;
import javautilArrayList;
import javautilList;
import orgapachestruts2jsonannotationsJSON;
import comopensymphonyxwork2Action;
import comszusstentityTBasMoniProject;
import comszusstserviceBaseService;
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 = baseServicequeryProjects(limit, start, key, num);
total = num[0];
success = true;
return SUCCESS;
}
public String savePro() {
success = baseServicesavePro(project);
return SUCCESS;
}
public String delete() {
long num = baseServicedeletePro(proIds);
if(num>0){
success = true;
}
return SUCCESS;
}
public String update() {
success = baseServiceupdatePro(project);
return SUCCESS;
}
public int getTotal() {
return total;
}
public List<TBasMoniProject> getList() {
return list;
}
public Boolean getSuccess() {
return success;
}
public void setBaseService(BaseService baseService) {
thisbaseService = baseService;
}
public void setLimit(int limit) {
thislimit = limit;
}
public void setStart(int start) {
thisstart = start;
}
public void setKey(String key) {
thiskey = key;
}
@JSON(serialize=false)
public TBasMoniProject getProject() {
return project;
}
public void setProject(TBasMoniProject project) {
thisproject = project;
}
public void setProIds(String proIds) {
thisproIds = proIds;
}
}
实体类:
package comszusstentity;
import javautilHashSet;
import javautilSet;
/
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) {
thisid = id;
}
public String getName() {
return name;
}
public void setName(String name) {
thisname = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
thiscode = code;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
thisunit = unit;
}
public Integer getDecimal() {
return decimal;
}
public void setDecimal(Integer decimal) {
thisdecimal = decimal;
}
public TOthSiteType getSiteType() {
return siteType;
}
public void setSiteType(TOthSiteType siteType) {
thissiteType = siteType;
}
public String getMaxNum() {
return maxNum;
}
public void setMaxNum(String maxNum) {
thismaxNum = maxNum;
}
public String getMinNum() {
return minNum;
}
public void setMinNum(String minNum) {
thisminNum = minNum;
}
public String getAlarmNum() {
return alarmNum;
}
public void setAlarmNum(String alarmNum) {
thisalarmNum = alarmNum;
}
public String getMask() {
return mask;
}
public void setMask(String mask) {
thismask = mask;
}
public String getGuobiaoNo() {
return guobiaoNo;
}
public void setGuobiaoNo(String guobiaoNo) {
thisguobiaoNo = guobiaoNo;
}
public String getShujuMk() {
return shujuMk;
}
public void setShujuMk(String shujuMk) {
thisshujuMk = shujuMk;
}
public Set<TBasMoniEquipment> getEquips() {
return equips;
}
public void setEquips(Set<TBasMoniEquipment> equips) {
thisequips = equips;
}
}
配置文件:
<action name="project" class="comszusstactionsiteProjectAction" >
<result name="success" type="json"></result>
</action>
然后就是配置好structs基本上就ok 。。。。
_ext表示扩展,指的是扩展表,是为了将基础表的字段扩展开来而创建的表,一般用于扩展记录字段数量,用来满足不同的需求或者特殊情况。添加进去的字段可以是新的,也可以是原有数据表中已有的字段,但是以_ext结尾加以区分。
不需要使用load来实现,使用store来 *** 作记录集
//定义一个数据模型
Extdefine('data', {
extend: 'ExtdataModel',
fields: ['val']
});
//定义一个记录集
var cData = Extcreate('ExtdataArrayStore',{
model: 'data',
data: [['数据1'],['数据2'],['数据3'],['数据4']]
});
//向已有的记录集插入新的数据,但是注意,这里只是在js数组里面添加了数据,要保存到数据库,还需在该函数后面添加ajax
function insert(){
var r = Extcreate('data', {val: '添加新的数据'});//这里的数据如果是用户输入的话,只需要换成那个文本框的值就行了,val: ExtgetCmp('xxxid号')getValue()
cDatainsert(0, r);
//ajax *** 作
alert('successfully done!');
}
//创建combo框
ExtonReady(function(){
var combo = Extcreate('ExtformfieldComboBox', {
store: cData,
fieldLabel: '下拉框',
displayField: 'val',
width: 498,
labelWidth: 60,
triggerAction: 'all',
renderTo: ExtgetBody()
});
});
把你的simpleStore换成一个JsonStore去后台load数据,再把combo的mode改为‘remote’就可以了,JsonStore的用法可以查询API文档或者baidu一下
什么是外部表?External table和正规的表很相似 具体的定义可以参见《Oracle概念手册》 以下的几点需要注意 >创建的语法类似于 CREATE TABLE ORGANIZATION EXTERNAL >数据在数据库的外部组织 是 *** 作系统文件 > *** 作系统文件在数据库中的标志是通过一个逻辑目录来映射的 >数据是只读的 (外部表相当于一个只读的虚表) >不可以在上面运行任何DML *** 作 不可以创建索引 >可以查询 *** 作和连接 可以并行 *** 作 例子 假定有如下的两个数据文件 平面文件数据的描述 假设如下的两个平面文件 datCode: [Copy to clipboard] SMITH CLERK DEC ALLEN SALESMAN FEB WARD SALESMAN FEB JONES MANAGER APR datCode: [Copy to clipboard] MARTIN SALESMAN SEP BLAKE MANAGER MAY MILLER CLERK JAN (要有对 *** 作系统中该目录的读写权限 )创建一个逻辑目录并进行适当授权Code: [Copy to clipboard] SQL> CREATE DIRECTORY TESTDIR AS D:\TEMP\ ;目录已创建 SQL> GRANT READ ON DIRECTORY TESTDIR TO DEMO;授权成功SQL> GRANT WRITE ON DIRECTORY TESTDIR TO DEMO;授权成功 注意 创建完毕逻辑目录之后要把平面文件拷贝到该目录下 另外还要注意文件名字不要写错创建外部表 Code: [Copy to clipboard] SQL> ED 已写入文件 afiedt buf CREATE TABLE DEMO EXT(emp_id number( ) ename varchar ( ) job varchar ( ) mgr_id number( ) hiredate date salary number( ) m number( ) dept_id number( )) [color=blue] ORGANIZATION EXTERNAL[/color]([color=blue]TYPE ORACLE_LOADER[/color]DEFAULT DIRECTORY TESTDIRACCESS PARAMETERS(RECORDS DELIMITED BY NEWLINEFIELDS TERMINATED BY ) LOCATION( DAT DAT )) SQL> /表已创建 进行Select选择 *** 作看看是否正确Code: [Copy to clipboard] SQL> select from DEMO EXT EMP_ID ENAME JOB MGR_ID HIREDATESALARY M DEPT_ID SMITH CLERK DEC ALLEN SALESMAN FEB WARDSALESMAN FEB JONES MANAGER APR MARTIN SALESMAN SEP BLAKE MANAGER MAY MILLER CLERK JAN 如果要得到外部表的有关信息Code: [Copy to clipboard] SQL> DESC DBA_EXTERNAL_TABLES; 名称 OWNER TABLE_NAMETYPE_OWNERTYPE_NAME DEFAULT_DIRECTORY_OWNERDEFAULT_DIRECTORY_NAMEREJECT_LIMIT ACCESS_TYPEACCESS_PARAMETERS SQL> SELECT OWNER TABLE_NAME DEFAULT_DIRECTORY_NAME ACCESS_PARAMETERSFROMDBA_EXTERNAL_TABLES;OWNERTABLE_NAMEDEFAULT_DIRECTORY_NAME ACCESS_PARAMETERS DEMO EXT TESTDIR RECORDS DELIMITED BY NEWLINEFIELDS TERMINATED BY 如果DBA想要知道平面文件的位置 使用如下的查询Code: [Copy to clipboard] SQL> desc DBA_EXTERNAL_LOCATIONS;名称 OWNER TABLE_NAMELOCATION DIRECTORY_OWNERDIRECTORY_NAMESQL> select from DBA_EXTERNAL_LOCATIONS;OWNER TABLE_NAME LOCATIONDIR DIRECTORY_NAME DEMO EXT DAT SYS TESTDIR DEMO EXT DAT SYS TESTDIR lishixinzhi/Article/program/Oracle/201311/16715
是不是extjs
如果是这个,那么有个示例给你看看,由于不知道你的数据表,所以只能是通用的。
net后台返回的数据格式如下:
{totalProperty:100,root:[{'id':'0','name':'name0','descn':'descn0'},{'id':'1','name':'name1','descn':'descn1'},{'id':'2','name':'name2','descn':'descn2'},{'id':'3','name':'name3','descn':'descn3'},{'id':'4','name':'name4','descn':'descn4'},{'id':'5','name':'name5','descn':'descn5'},{'id':'6','name':'name6','descn':'descn6'},{'id':'7','name':'name7','descn':'descn7'},{'id':'8','name':'name8','descn':'descn8'},{'id':'9','name':'name9','descn':'descn9'}]}
extjs代码如下:
ExtonReady(function(){
var sm = new ExtgridCheckboxSelectionModel();
var cm = new ExtgridColumnModel([
new ExtgridRowNumberer(),
sm,
{header:'编号',dataIndex:'id'},
{header:'性别',dataIndex:'sex'},
{header:'名称',dataIndex:'name'},
{header:'描述',dataIndex:'descn'}
]);
cmdefaultSortable = true;
var ds = new ExtdataStore({
proxy: new Extdata>
以上就是关于请问Ext中如何用循环全部的内容,包括:请问Ext中如何用循环、extjs+mvc给Ext表单添加数据,然后以实体的形式返回到后台、数据库表名后面_ext是什么意思等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)