extjs html table,基于ExtJS Grid创建Table例子

基本思路:

基于ExtJS4.1版本开发,主要是首先创建一个Data Model组件,mockup一些JSON数据

然后将data Model与JSON数据绑定到创建的data store中,最后创建grid组件同时绑定

之前的data store完成整个程序。

一个简单ExtJS组件结构图:

1344480856_9774.png

程序运行结果如下:

1344481042_9738.png

JavaScript部分的源代码如下:

Ext.require([ 'Ext.grid.*', 'Ext.data.*', 'Ext.util.*', 'Ext.state.*' ]); Ext.onReady(function() { // mock up data // sample static data for the store var myData = [ ['gloomyfish',31, 'M', 'software', '09 July 1980'], ['Mike',31, 'M', 'software', '09 July 1984'], ['Green Mook',31, 'M', 'software', '09 July 1980'], ['Rose Kate',25, 'F', 'software', '09 July 1987'], ['Dave Wu',28, 'M', 'software', '24 July 1984'], ['Hong Naa',31, 'M', 'software', '09 July 1980'] ]; // create data model Ext.define('EmplyeeInfo', { extend: 'Ext.data.Model', fields: [ {name: 'employee', type: 'string'}, {name: 'age', type: 'int'}, {name: 'gentle', type: 'string'}, {name: 'department', type: 'string'}, {name: 'birthday', type: 'date', dateFormat: 'd F Y'} ], }); // create the data store var store = Ext.create('Ext.data.ArrayStore', { model: 'EmplyeeInfo', data: myData }); // create the Grid var grid = Ext.create('Ext.grid.Panel', { store: store, columns: [ { text : 'Employee Name', flex : 1, sortable : false, dataIndex: 'employee' }, { text : 'Age', width : 75, sortable : true, dataIndex: 'age' }, { text : 'Gentle', width : 75, sortable : true, dataIndex: 'gentle' }, { text : 'Department', width : 75, sortable : true, dataIndex: 'department' }, { text : 'Birthday Date', width : 85, sortable : true, renderer : Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'birthday' } ], height: 350, width: 600, title: 'Employee Information Table', renderTo: 'grid-example', viewConfig: { stripeRows: true } }); });HTML部分的源代码如下:

Hello Ext

My Fist Grid Table - ExtJS 4.1

This example shows how to create a grid from Array data.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值