zoukankan      html  css  js  c++  java
  • ExtJs之表格控件

    一、 功能:排序、拖动、隐藏某一列、自动显示行号、单元格编辑等。

    二、由类Ext.grid.GridPanel定义,继承自Panel,xtype为grid,列信息由类Ext.grid.ColumnModel定义,数据存储由Ext.data.Store定义。数据存储器根据解析的数据部同分为JsonStore、SimpleStore、GroupingStore等。

      一个简单的使用表格控件的例子:

    function ShowUrl(value){
      alert(value);
    };
    Ext.onReady(function(){
      //定义一个数组
      var data = [
                  [1,'标题1','内容1','详细内容1'],
                  [2,'标题2','内容2','详细内容2'],
                  [3,'标题3','内容3','详细内容3']
                ];

    //定义个数据存储器(必须) var store = new Ext.data.SimpleStore({
    data:data,
    fields:["id","title","content","url"]
    });

    //定义列信息(必须) var colM = new Ext.grid.ColumnModel( { header:"ID",dataIndex:"id",sortable:true }, { header:"标题",dataIndex:"title",sortable:true }, { header:"内容",dataIndex:"content",sortable:true }, { header:"链接",dataIndex:"url",sortable:true,renderer:ShowUrl});

    //创建一个GridPanel var grid = Ext.grid.GridPanel({ title:"测试标题", height:150, 600, cm:colM, store:store, autoExpandColumn:2, renderTo:"htmlId" //渲染表格到ID为htmlId的容器中 }); })
       header列头显示的文本、dataIndex列对应的记录集字段(上面的fields)、sortable列是否可排序、renderer列的渲染函数、ShowUrl为自定义函数

      上面的例子虽然简单,但是创建一个表格应该需要哪些准备元素都一一标明出来。对于需求复杂的表格,只是针对Ext.data.Store 的设定。接下来我们将要讨论针对不同的需求对数据存储器的复杂应用。

  • 相关阅读:
    我的浏览器和常用扩展
    Win10安装.Net Framework4.7及更高版本
    压缩和解压工具bandizip
    Oracle trunc()函数的用法
    Oracle 中 decode 函数用法
    Js/Jquery获取iframe中的元素 在Iframe中获取父窗体的元素方法
    String literal is not properly closed by a double-quote eclipse
    linux 启动 Oracle 实例
    查询当前Oracle数据库的实例
    sqlplus 执行 sql 文件
  • 原文地址:https://www.cnblogs.com/mdorg/p/2817787.html
Copyright © 2011-2022 走看看