PHP学会网 php培训网 PHP暑期培训 PHP寒假培训 PHP假期培训 » YUI,ext JS » 是用Ext.grid的初始化步骤总结
本页主题: 是用Ext.grid的初始化步骤总结 打印 | 加为IE收藏 | 收藏主题 | 上一主题 | 下一主题

phpwhy

头衔:总管 总管
该用户目前不在线
级别: 管理员
精华: 3
发帖: 633
威望: 550 点
金钱: 5560 PYMB
贡献值: 0 点
在线时间:12(小时)
注册时间:2005-09-15
最后登录:2008-11-25

是用Ext.grid的初始化步骤总结


1、初始化Proxy参数

js 代码

var proxyParam={ 
        url:'http://localhost:8080/demo2/login/index', 
        method"'GET' 
    }; 
2、初始化JsonReader Meta参数

js 代码

var jsonReaderMeta={ 
        root: 'items', 
        totalProperty: 'totalCount', 
        id: 'id' 
    }; 
3、初始化JsonReader RecordType参数

js 代码

var recordType=[ 
            {name: 'title', mapping: 'title'}, 
            {name: 'author', mapping: 'author'}, 
            {name: 'totalPosts', mapping: 'totalPosts', type: 'int'}, 
            {name: 'lastPost', mapping: 'lastPost'}, 
            {name: 'postText', mapping: 'post_text'} 
      ]; 
4、初始化Grid ColumnModel参数

js 代码
var columnModel=[{ 
          id: 'topic', 

          header: "Topic", 
          dataIndex: 'title', 
          width: 490, 
          renderer: renderTopic, 
          css: 'white-space:normal;' 
        },{ 
          header: "Author", 
          dataIndex: 'author', 
          width: 100, 
          hidden: true 
        },{ 
          id: 'last', 
          header: "Last Post", 
          dataIndex: 'lastPost', 
          width: 150, 
          renderer: renderLast 
        }]; 
5、初始化Data Store

js 代码
var ds = new Ext.data.Store({ 
        proxy: new Ext.data.HttpProxy(proxyParam), 
        reader: new Ext.data.JsonReader(jsonReaderMeta,recordType), 
        remoteSort: true 
    }); 
6、初始化ColumnModel

js 代码
var cm = new Ext.grid.ColumnModel(columnModel); 
7、终于该grid出场了

js 代码
var grid = new Ext.grid.Grid('topic-grid', { 
        ds: ds, 
        cm: cm, 
        selModel: new Ext.grid.RowSelectionModel({singleSelect:true}), 
        enableColLock:false, 
        loadMask: true 
    }); 
从上面的过程来看,可以显示对grid的封装,同一类功能的界面可以有一个函数来构建一个grid,只要传入不同的初始化参数就可以了。
你适合当程序员吗?给想学编程的朋友
http://www.phpwhy.com/read.php?tid=5258&page=1&toread=1

  远程免费试听http://www.phpwhy.com/bbs/read.php?tid=4514
学校照片见 http://www.phpwhy.com/bbs/read.php?tid=4091


PHP培训,网站建设咨询
联系电话: 0571-85980046 ,0571-86704910
联系人:何老师
qq:310172
地址:杭州下沙4号路物美西子阳光星城1座501室智达电脑培训中心
顶端 Posted: 2008-01-20 20:50 | [楼 主]
PHP学会网 php培训网 PHP暑期培训 PHP寒假培训 PHP假期培训 » YUI,ext JS

时:01-09 12:35 Copyright © 2006 phpwhy.com 权
ICP05060669

曳息 -