美文网首页
EXT.js学习(二)

EXT.js学习(二)

作者: 冰已凋零 | 来源:发表于2017-03-15 16:54 被阅读0次

按钮

使用 listeners 配置添加更多的事件处理器

Ext.create('Ext.Button', {   
    text: 'My Button',   
    renderTo: Ext.getBody(),   
    listeners: {     
        click: {       
            fn: function(){
                //Handle click event         
                alert('click');
            }
        },
        mouseout: {       
            fn: function(){
                //Handle double click event         
                alert('Mouse out');
             }
        }
    }
});
Ext.MessageBox.show({   
    title:'Save Changes?',   
    msg: 'Do you want to save the file?',   
    buttons: Ext.MessageBox.YESNO,   
    // 自定义: 
    buttonText: {yes:'ok?'},
    fn: function(button){     
        if('yes'==button){
 
        }else if('no'==button){
 
        }   
    },
    icon: Ext.MessageBox.QUESTION 
}) ;

Store?

下列代码是一个 store 的例子,它使用 RESTful API 请求加载为 JSON 格式数据:
var myStore = Ext.create('Ext.data.Store', {
    model: 'Employee',   
    storeId: 'mystore',   
    proxy: {     
        type: 'rest',     
        url: '/employee',     
        reader: {       
            type: 'json',       
            rootProperty: 'data'
        }
    },   
    autoLoad: true,   
    autoSync: true 
});
store-grid
  1. 通过renderer向数据添加HTML,URL,图片,符号
  2. 过滤
    通过添加 Ext.grid.filters.Filters (ptype: gridfilters) 插件到 grid 并对列进行配置可以很容易实现过滤功能:
Ext.application({   
    name : 'Fiddle',   
    launch : function() {
        Ext.create('Ext.grid.Panel', {   
            renderTo: Ext.getBody(),   
            store: productStore,
            // gridfilters插件 -- 筛选
            plugins: 'gridfilters',
            width: 600,   
            title: 'Products',   
            columns: [{     
                text: 'Id',     
                dataIndex: 'id',     
                hidden: true
            },{     
                text: 'Name',     
                width:150,
                dataIndex: 'productname',
                // 设置筛选格式
                filter:'string'
            },{
                text: 'Description',     
                dataIndex: 'desc',     
                sortable: false,     
                flex: 1,
                // 设置筛选格式
                filter: {       
                    type: 'string',
                    itemDefaults: {   
                        emptyText: 'Search for…' 
                    }
                }
            },{     
                text: 'price',     
                width: 100,     
                dataIndex: 'price',
                renderer: function(value){
                    // 添加'$'符号
                    return Ext.String.format('${0}',value);
                }
            }]
        });
      }
});
// store数据
Ext.define('Product', {   
    extend: 'Ext.data.Model',
    fields: [ 'id', 'productname', 'desc', 'price' ] 
});
var productStore = Ext.create('Ext.data.Store', {
    model: 'Product',   
    data: [{     
        id: 'P1',
        productname: 'Ice Pop Maker',
        desc: 'Create fun and healthy treats anytime',
        price: '16.33'
    }, {     
        id: 'P2',
        productname: 'Stainless Steel Food Jar',     
        desc: 'Thermos double wall vacuum insulated food jar',
        price: '14.87'
    },{     
        id: 'P3',
        productname: 'Shower Caddy',
        desc: 'Non-slip grip keeps your caddy in place',
        price: '17.99'
    }, {     
        id: 'P4',
        productname: 'VoIP Phone Adapter',
        desc: 'Works with Up to Four VoIP Services Across One Phone Port',
        price: '47.50'
    }] 
});
store-grid

相关文章

  • EXT.js学习(二)

    按钮 使用 listeners 配置添加更多的事件处理器 Store? 下列代码是一个 store 的例子,它使用...

  • EXT.js学习(一)

    application.js extend 会创建一个新的类,并继承父类的属性和方法,你也可以重写父类的方法。而 ...

  • EXT.js学习(三)

    tree panel 拖拽 treeviewdragdrop

  • EXT.js学习(四)

    自定义数据模型 在上一节中,我们使用Ext.define 来自定义类,通过Ext.define 定义的类都默认继承...

  • EXT.js学习(MVC)

    Ext JS鼓励用户利用结构化的应用程序架构。在我们的示例中,我们使用MVC(模型/视图/控制器)方法。这有助于我...

  • Webpack之“多页面开发”配置

    ​ 目前在负责公司的一个前端项目,现有的版本是基于Ext.js框架进行搭建,但Ext.js显得过重,而且构建后...

  • 小程序端扩展文件

    ext.js { "extEnable":true, "extAppid":"你的appid", "directC...

  • EXT.js学习(数据绑定)

    任何组件配置都可以使用绑定,只要它有一个 setter 方法。在这种情况下,我们将记录的 firstName 字段...

  • vue+element ui 之一:环境搭建和项目创建

    替换老技术ext.js,故而用Element UI。 node安装(npm跟node是配套的,无须单独安装),去官...

  • Ext.js Class类

    Ext是一个单例对象,对象下面有方法和类 方法 application 还没看懂 define 用来定义或重写一...

网友评论

      本文标题:EXT.js学习(二)

      本文链接:https://www.haomeiwen.com/subject/tbvlnttx.html