ext读取xml内容
来源:互联网 发布:淘客软件定制 编辑:程序博客网 时间:2024/05/20 18:53
这里是一个老例子哈
建立一个xml文件:plants.xml
<?xml version="1.0" encoding="utf-8"?>
<catalog>
<plant>
<common>Bloodroot</common>
<botanical>Sanguinaria canadensis</botanical>
<zone>4</zone>
<light>Mostly Shady</light>
<price>2.44</price>
<availability>03/15/2006</availability>
<indoor>true</indoor>
</plant>
<plant>
<common>Columbine</common>
<botanical>Aquilegia canadensis</botanical>
<zone>3</zone>
<light>Mostly Shady</light>
<price>9.37</price>
<availability>03/06/2006</availability>
<indoor>true</indoor>
</plant>
</catalog>
建立js:load.js
Ext.onReady(function(){
Ext.QuickTips.init();
function formatDate(value){
return value ? value.dateFormat('M d, Y') : '';
};
// shorthand alias
var fm = Ext.form;
// custom column plugin example
var checkColumn = new Ext.grid.CheckColumn({
header: "Indoor?",
dataIndex: 'indoor',
width: 55
});
// the column model has information about grid columns
// dataIndex maps the column to the specific data field in
// the data store (created below)
var cm = new Ext.grid.ColumnModel([{
id:'common',
header: "Common Name",
dataIndex: 'common',
width: 220,
editor: new fm.TextField({
allowBlank: false
})
},{
header: "Light",
dataIndex: 'light',
width: 130,
editor: new Ext.form.ComboBox({
typeAhead: true,
triggerAction: 'all',
transform:'light',
lazyRender:true,
listClass: 'x-combo-list-small'
})
},{
header: "Price",
dataIndex: 'price',
width: 70,
align: 'right',
renderer: 'usMoney',
editor: new fm.NumberField({
allowBlank: false,
allowNegative: false,
maxValue: 100000
})
},{
header: "Available",
dataIndex: 'availDate',
width: 95,
renderer: formatDate,
editor: new fm.DateField({
format: 'm/d/y',
minValue: '01/01/06',
disabledDays: [0, 6],
disabledDaysText: 'Plants are not available on the weekends'
})
},
checkColumn
]);
// by default columns are sortable
cm.defaultSortable = true;
// this could be inline, but we want to define the Plant record
// type so we can add records dynamically
var Plant = Ext.data.Record.create([
// the "name" below matches the tag name to read, except "availDate"
// which is mapped to the tag "availability"
{name: 'common', type: 'string'},
{name: 'botanical', type: 'string'},
{name: 'light'},
{name: 'price', type: 'float'}, // automatic date conversions
{name: 'availDate', mapping: 'availability', type: 'date', dateFormat: 'm/d/Y'},
{name: 'indoor', type: 'bool'}
]);
// create the Data Store
var store = new Ext.data.Store({
// load using HTTP
url: 'jsp/xtcs/rysz/plants.xml',//这个地方是相对路径
// the return will be XML, so lets set up a reader
reader: new Ext.data.XmlReader({
// records will have a "plant" tag
record: 'plant'
}, Plant),
sortInfo:{field:'common', direction:'ASC'}
});
// create the editor grid
var grid = new Ext.grid.EditorGridPanel({
store: store,
cm: cm,
renderTo: 'editor-grid',
width:600,
height:300,
autoExpandColumn:'common',
title:'Edit Plants?',
frame:true,
plugins:checkColumn,
clicksToEdit:1,
tbar: [{
text: 'Add Plant',
handler : function(){
var p = new Plant({
common: 'New Plant 1',
light: 'Mostly Shade',
price: 0,
availDate: (new Date()).clearTime(),
indoor: false
});
grid.stopEditing();
store.insert(0, p);
grid.startEditing(0, 0);
}
}]
});
// trigger the data store load
store.load();
});
Ext.grid.CheckColumn = function(config){
Ext.apply(this, config);
if(!this.id){
this.id = Ext.id();
}
this.renderer = this.renderer.createDelegate(this);
};
Ext.grid.CheckColumn.prototype ={
init : function(grid){
this.grid = grid;
this.grid.on('render', function(){
var view = this.grid.getView();
view.mainBody.on('mousedown', this.onMouseDown, this);
}, this);
},
onMouseDown : function(e, t){
if(t.className && t.className.indexOf('x-grid3-cc-'+this.id) != -1){
e.stopEvent();
var index = this.grid.getView().findRowIndex(t);
var record = this.grid.store.getAt(index);
record.set(this.dataIndex, !record.data[this.dataIndex]);
}
},
renderer : function(v, p, record){
p.css += ' x-grid3-check-col-td';
return '<div class="x-grid3-check-col'+(v?'-on':'')+' x-grid3-cc-'+this.id+'"> </div>';
}
};
建立jsp:index.jsp
<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c"%>
<html>
<head>
<title>人员配置</title>
<link media="all" rel="stylesheet" href="l/resources/css/ext-all.css"
type="text/css">
<link media="all" rel="stylesheet"
href="l/resources/css/xtheme-silverCherry.css" type="text/css">
<script type="text/javascript" src="l/k/k1.gzjs"></script>
<script type="text/javascript" src="l/k/k.gzjs"></script>
<script type="text/javascript" src="l/k/k2.gzjs"></script>
<script type="text/javascript" src="l/k/util.js"></script>
<script type="text/javascript" src="l/k/examples.js"></script>
<script type="text/javascript" src="jsp/xtcs/rysz/load.js"></script>//这里具体要改成工程引用的路径
</head>
<body>
<!-- EXAMPLES
<input type="button" id="show-btn" value="Hello World" />
<br />
<br />
<div id="hello-win" class="x-hidden">
<div class="x-window-header">
Hello Dialog
</div>
<div id="hello-tabs">
<div class="x-tab" title="Hello World 1">
<input type="text" name="aa">
</div>
<div class="x-tab" title="Hello World 2">
<p>
... World!
</p>
</div>
<div class="x-tab" title="Hello World 3">
<p>
... World 3!
</p>
</div>
<div id="grid-example"></div>-->
<select name="light" id="light" style="display: none;">
<option value="Shade">
Shade
</option>
<option value="Mostly Shady">
Mostly Shady
</option>
<option value="Sun or Shade">
Sun or Shade
</option>
<option value="Mostly Sunny">
Mostly Sunny
</option>
<option value="Sunny">
Sunny
</option>
</select>
<div id="editor-grid"></div>
</body>
</html>
- ext读取xml内容
- 读取xml文件内容
- XPath读取Xml内容
- XPath读取Xml内容
- 读取XML..内容
- 读取XML文件内容
- 读取XML格式文件内容
- C#读取XML内容
- 读取XML的内容
- Ext.data.Store 读取XML属性值
- Ext.data.Store 读取XML属性值
- FLASH读取XML中的内容
- 如何读取XML文件内容!
- 如何读取XML文件内容
- Unity3D读取XML内容代码
- 创建xml并写入,读取xml内容
- 【Unity&XML】读取XML文件内容
- XML文档追加内容,查找(读取)内容 ,删除内容
- windows 驱动程序开发
- vs.net2008破解
- 面向对象的六大原则(推荐)
- bat教程
- 基于角色访问控制的权限系统设计
- ext读取xml内容
- SQL注入天书—ASP注入漏洞全接触
- wml表单提交
- 面试题
- Linux-2.6.20内核移植到AT91RM9200-EK
- 谈谈java 反射机制
- 位运算:右移,左旋转,右旋转
- 如何设置Outlook/Foxmail软件?
- 自由拼音输入法的测试