zoukankan      html  css  js  c++  java
  • extjs基本例子

    这是一个.js文件   
    Ext.onReady(function() {
    /*root  获取json的值   autoLoad  自动装载   fields需要的值*/
        var store = new Ext.data.JsonStore({
            url:'action/do_post.jsp?method=list',
            root:'rows',
            autoLoad:true,
            fields:['postId','content','title',{name: 'createDate'}]
        });
     
     
        // create the Grid               
        var grid = new Ext.grid.GridPanel({
            store: store,                  /*调用上面的对象*/
            columns: [                    /*显示的列*/
                {
                    id       :'postId',        /*标示列*/
                    header   : 'postId',    
                    width    : 50,
                    sortable : true,          /*可排序*/
                    dataIndex: 'postId'    /*内连的字段*/
                },
                {
                    header   : 'content',
                    width    : 75,
                    sortable : true,
                    dataIndex: 'content'
                },
                {
                    header   : 'title',
                    width    : 75,
                    sortable : true,
                    dataIndex: 'title'
                }
                ,
                {
                    header   : 'date',
                    width    : 150,
                    sortable : true,
                    /*渲染这个方法,renderer一般加的就是方法,自己定的或者掉用的*/
                    renderer : Ext.util.Format.dateRenderer('m-d-Y H:m:s'),   
                    dataIndex: 'createDate'
                }
            ],
     
            height: 350,
            600,
            title: 'Array Grid'
           
        });
     
        // render the grid to the specified div in the page
        grid.render('grid-example');      /*对应前台的div      <div id="grid-example"></div>*/
    });
     
    /*对应的查询页面
    // json
        final JSONObject results = new JSONObject();
        JSONArray results2 = new JSONArray();
    //处理复杂数据  
        JsonConfig jsonConfig = new JsonConfig();
        jsonConfig.registerJsonValueProcessor(Date.class, new DateJsonValueProcessorImpl());
     
    if (method.equals("list")) {
            try {
                List<Post> post_list = genericService.list(Post.class, "ORDER BY createdate ASC");
                results2 = JSONArray.fromObject(post_list,jsonConfig);
                results.element("rows", results2);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        out.print(results);
    */
  • 相关阅读:
    使用Areas分离ASP.NET MVC项目
    将json转化为model
    简单的三层asp.net webForm使用Ninject实现Ioc
    本机连接虚拟机Oracle时报错的解决办法
    老电脑升级
    安装Oracle时选择桌面类和服务器类的区别
    64位操作系统下启用32位模式
    log4net在WinForm和ASP.net下的设置
    Delphi2009下编译提示“无法找到“Excel_TLB”
    Delphi 中的MD5实现方法(转)
  • 原文地址:https://www.cnblogs.com/lixin890808/p/3092535.html
Copyright © 2011-2022 走看看