extjs_02_grid(顯示本機資料,顯示跨域資料)

來源:互聯網
上載者:User

1.顯示表格

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>My JSP 'index.jsp' starting page</title><link rel="stylesheet" type="text/css" href="./extjs4.1/resources/css/ext-all.css"><script type="text/javascript" src="./extjs4.1/ext-all-debug.js"></script><script type="text/javascript" src="./extjs4.1/locale/ext-lang-zh_CN.js"></script><script type="text/javascript">Ext.onReady(function() {// 定義表格var grid = new Ext.grid.Panel({columns : [ {text : '行號'}, {text : '學號'}, {text : '姓名'}, {text : '班級'}, {text : '語文'}, {text : '數學'}, {text : '英語'} ]});// 定義視窗var window = Ext.create("Ext.window.Window", {title : '學產生績表',width : 600,height : 400,items : grid,layout : 'fit'//表格填充視窗});// 顯示視窗window.show();});</script></head><body>顯示表格<br></body></html>

2.顯示本機資料

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>My JSP 'index.jsp' starting page</title><link rel="stylesheet" type="text/css" href="./extjs4.1/resources/css/ext-all.css"><script type="text/javascript" src="./extjs4.1/ext-all-debug.js"></script><script type="text/javascript" src="./extjs4.1/locale/ext-lang-zh_CN.js"></script><script type="text/javascript">Ext.onReady(function() {// 自訂資料模型var myModel = Ext.define("studentInfo", {extend : 'Ext.data.Model',fields : [ {name : 'stuNo',type : 'string'}, {name : 'stuName',type : 'string'}, {name : 'stuClass',type : 'string'}, {name : 'chScore',type : 'number'}, {name : 'maScore',type : 'number'}, {name : 'enScore',type : 'number'} ]});// 本機資料var myData = [ [ 'No1', 'wangzs1', '1年級', 80, 67, 49 ],[ 'No2', 'wangzs2', '2年級', 65, 57, 79 ],[ 'No3', 'wangzs3', '3年級', 45, 77, 59 ],[ 'No4', 'wangzs4', '4年級', 99, 27, 19 ],[ 'No5', 'wangzs5', '5年級', 23, 97, 99 ],[ 'No6', 'wangzs6', '6年級', 34, 67, 99 ], ];var myStore = Ext.create("Ext.data.Store", {model : 'studentInfo',data : myData});// 表格var myGrid = new Ext.grid.Panel({columns : [ {xtype : 'rownumberer',text : '行號'}, {text : '學號',dataIndex : 'stuNo'}, {text : '姓名',dataIndex : 'stuName'}, {text : '班級',dataIndex : 'stuClass'}, {text : '語文',dataIndex : 'chScore'}, {text : '數學',dataIndex : 'maScore'}, {text : '英語',dataIndex : 'enScore'} ],store : myStore});// 視窗var window = Ext.create("Ext.window.Window", {title : '學產生績表',width : 600,height : 400,items : myGrid,layout : 'fit'});window.show();});</script></head><body>顯示本機資料<br></body></html>

3.顯示跨域jsonp資料

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>My JSP 'index.jsp' starting page</title><link rel="stylesheet" type="text/css" href="./extjs4.1/resources/css/ext-all.css"><script type="text/javascript" src="./extjs4.1/ext-all-debug.js"></script><script type="text/javascript" src="./extjs4.1/locale/ext-lang-zh_CN.js"></script><script type="text/javascript">Ext.onReady(function() {// 自訂資料模型var jsonpModel = Ext.define("jsonpModel", {extend : 'Ext.data.Model',fields : [ {name : 'userid',type : 'string'}, {name : 'username',type : 'string'}, {name : 'dateline',type : 'string'}, {name : 'title',type : 'string'} ]});// 資料var myStore = Ext.create("Ext.data.Store", {model : 'jsonpModel',pageSize : 10,//配置每頁顯示記錄數proxy : {type : 'jsonp',url : 'http://www.sencha.com/forum/topics-browse-remote.php',reader : {totalProperty : 'totalCount',root : 'topics'}},autoLoad : true// 自動載入資料});// 表格var myGrid = new Ext.grid.Panel({columns : [ {xtype : 'rownumberer',text : '行號'}, {text : '使用者id',dataIndex : 'userid'}, {text : '使用者姓名',dataIndex : 'username'}, {text : '時間軸',dataIndex : 'dateline'}, {text : '標題',dataIndex : 'title'} ],store : myStore,bbar : {// 在表格底部 配置分頁xtype : 'pagingtoolbar',store : myStore,displayInfo : true}});// 視窗var window = Ext.create("Ext.window.Window", {title : '學產生績表',width : 600,height : 400,items : myGrid,layout : 'fit'});window.show();});</script></head><body>顯示跨域jsonp資料<br></body></html>


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.