API:http://10.20.138.27/ext-3.4.0/docs/
ExtJS API文档的使用方法详解:http://www.cnblogs.com/liberD/archive/2011/09/12/2173997.html
extjs中文站:http://ajaxjs.com/
Sample:http://10.20.138.27/ext-3.4.0/examples/
source download:http://www.sencha.com/products/extjs3/download/ext-js-3.4.0/203
ext扩展组件rowaction:http://rowactions.extjs.eu/
参考:《ExtJS实用开发指南》
1、function和Function区别
function:js的保留关键字
Function:ext的类
2、多个tab
- var tabs = new Ext.TabPanel({
- renderTo: Ext.getBody(),
- activeTab: 0,
- items: [{
- title: 'Tab 1',
- html: 'A simple tab'
- },{
- title: 'Tab 2',
- html: 'Another one'
- }]
- });
3、结构关系图
4、绘图,需要有绘图的工具charts.swf文件
- function generateData() {
- var data = [];
- for ( var i = 0; i < 12; ++i) {
- data.push([ Date.monthNames[i],
- (Math.floor(Math.random() * 11) + 1) * 100 ]);
- }
- return data;
- }
- Ext.onReady(function() {
- var store = new Ext.data.ArrayStore({
- fields : [ 'month', 'hits' ],
- data : generateData()
- });
- new Ext.Panel({
- width : 700,
- height : 400,
- renderTo : document.body,
- title : 'Column Chart with Reload - Hits per Month',
- tbar : [ {
- text : 'Load new data set',
- handler : function() {
- store.loadData(generateData());
- }
- } ],
- items : {
- xtype : 'columnchart',
- store : store,
- yField : 'hits',
- url : 'charts.swf',
- xField : 'month',
- xAxis : new Ext.chart.CategoryAxis({
- title : 'Month'
- }),
- yAxis : new Ext.chart.NumericAxis({
- title : 'Hits'
- }),
- extraStyle : {
- xAxis : {
- labelRotation : -90
- }
- }
- }
- });
- });
xtype:columnchart含义:表示整个item的别称,代表item,用于延迟加载。url属性:需要找columnchart的相关API,可以查看帮助文档中的Ext.Component,其中包含了大量的xtype别名。
5、Tree展示:
- new Ext.onReady(function() {
- var tree = new Ext.tree.TreePanel({
- title : "this is a tree",
- width : 200,
- height : 200,
- loader : new Ext.tree.TreeLoader(),
- root : new Ext.tree.AsyncTreeNode({
- text : "root",
- children : [{
- text : "leaf 1",
- leaf : true
- }, {
- text : "leaf 2",
- leaf : true
- }]
- })
- })
- tree.render("main");
- /*
- * var config = { title : "this is title", width : 400, height : 300,
- * buttons : [{ text : "确定" }, { text : "取消" }] }; var win = new
- * Ext.Window(config); win.show();
- */
- });
html中使用:
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <link rel="stylesheet" type="text/css"
- href="common/extlib/resources/css/ext-all.css" />
- <link rel="stylesheet" type="text/css"
- href="common/extlib/resources/css/ext-font-patch.css" />
- <link rel="stylesheet" type="text/css" href="common/css/common.css" />
- <script type="text/javascript"
- src="common/extlib/adapter/ext/ext-base.js"></script>
- <script type="text/javascript" src="common/extlib/ext-all.js"></script>
- <script type="text/javascript" src="common/js/utils.js"></script>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>Insert title here</title>
- </head>
- <body>
- <script type="text/javascript" src="sample.js"></script>
- <div id="main"></div>
- </body>
- </html>
6、网站管理后台
- Ext.onReady(function() {
- new Ext.Viewport({
- enableTabScroll : true,
- layout : "border",
- items : [{
- title : "面板",
- region : "north",
- height : 100,
- html : "<h1>网站后台管理系统!</h1>"
- }, {
- title : "菜单",
- region : "west",
- width : 200,
- collapsible : true,
- html : "菜单栏"
- }, {
- xtype : "tabpanel",
- region : "center",
- items : [{
- title : "面板1"
- }, {
- title : "面板2"
- }]
- }]
- });
- });
7、表格
- Ext.onReady(function() {
- var data = [[1, 'EasyJWeb', 'EasyJF', 'www.easyjf.com'],
- [2, 'jfox', 'huihoo', 'www.huihoo.org'],
- [3, 'jdon', 'jdon', 'www.jdon.com'],
- [4, 'springside', 'springside', 'www.springside.org.cn']];
- var store = new Ext.data.SimpleStore({
- data : data,
- fields : ["id", "name", "organization", "homepage"]
- });
- var colM = new Ext.grid.ColumnModel([{
- header : "项目名称",
- dataIndex : "name",
- sortable : true
- }, {
- header : "开发团队",
- dataIndex : "organization",
- sortable : true
- }, {
- header : "网址",
- dataIndex : "homepage"
- }]);
- var grid = new Ext.grid.GridPanel({
- renderTo : "hello",
- title : "中国Java开源产品及团队",
- height : 200,
- width : 600,
- cm : colM,
- store : store,
- autoExpandColumn : 2
- });
- });
8、数据的返回:fields
- this.store = new Ext.data.JsonStore({
- url : '../../hummockWhiteList/searchWhiteList.do',
- totalProperty : 'total',
- idProperty : 'id',
- root : 'data',
- remoteSort : true,
- fields : ['id', 'appId', 'listKey', 'listValue',
- 'validationTime', 'accessNum',
- 'discription']
- });
9、ext核心组件
事件监听:Ext.util.Observable
组件:Ext.Component
方形的组件:Ext.BoxComponent
autoHeight : Boolean,自动适应屏幕的高度
autoScroll : Boolean,出现滚动条
容器:Ext.Container
activeItem :设置某一个为活动状态
defaultType: button
items :[{ text("按钮1")},text("按钮2")} 放东西
layout :
.on:添加事件
listeners : { click :btnClick() }
10、点击按钮“mybutton”,显示window
- new Ext.onReady(function() {
- var window = new Ext.Window({
- width : 400,
- height : 300,
- title : 'alibaba'
- });
- Ext.get("mybutton").on("click", function() {
- //Ext.Msg.alert('Status', 'Changes saved successfully.');
- window.show();
- });
- });