zoukankan      html  css  js  c++  java
  • 设置 Ext.data.Store 传参的请求方式

    设置 Ext.data.Store 传参的请求方式

    1.extjs 给怎么给panel设背景色

    设置bodyStyle:'background:#ffc;padding:10px;',

    复制代码
    var resultsPanel = Ext.create('Ext.panel.Panel', {
        title: 'Results',
         600,
        height: 400,
        renderTo: Ext.getBody(),
        bodyStyle: 'background:#ffc; padding:10px;',
        layout: {
            type: 'vbox',       // Arrange child items vertically
            align: 'stretch',    // Each takes up full width
            padding: 5
        },
        items: [{               // Results grid specified as a config object with an xtype of 'grid'
            xtype: 'grid',
            columns: [{header: 'Column One'}],            // One header just for show. There's no data,
            store: Ext.create('Ext.data.ArrayStore', {}), // A dummy empty data store
            flex: 1                                       // Use 1/3 of Container's height (hint to Box layout)
        }, {
            xtype: 'splitter'   // A splitter between the two child items
        }, {                    // Details Panel specified as a config object (no xtype defaults to 'panel').
            title: 'Details',
            bodyPadding: 10,
            items: [{
                fieldLabel: 'Data item',
                xtype: 'textfield'
            }], // An array of form fields
            flex: 2             // Use 2/3 of Container's height (hint to Box layout)
        }]
    });
    复制代码

    2. Extjs4.0 设置 Ext.data.Store 传参的请求方式

    复制代码
    var Store = Ext.create('Ext.data.Store', {  
        pageSize: pageSize,  
        model: 'Ext.data.Model名称',  
        autoLoad: false,  
        proxy: {  
            type: 'ajax',  
            url: '请求路径',  
            getMethod: function(){ return 'POST'; },//亮点,设置请求方式,默认为GET  
            reader: {  
                type: 'json',  
                root: 'Data',  
                totalProperty: 'totalCount'  
            }  
        },   
        listeners: {  
            'beforeload': function (store, op, options) {  
                var params = {  
                    //参数  
                };  
                Ext.apply(store.proxy.extraParams, params);   
            }  
        }  
    });  
    复制代码

    3.ExtJS grid 带参数查询分页 store 传额外参数解决办法

    在store的beforeload事件里面重写store.proxy.extraParams,添加新参数

    就不必每次都手动的添加参数

    复制代码
    store.on('beforeload', function (store, options) {
            var new_params = { name: Ext.getCmp('search').getValue() };
            Ext.apply(store.proxy.extraParams, new_params);
            // alert('beforeload');
        });
    在Extjs3 中的
    store.on('beforeload', function () {
                store.baseParams = {
                    name: '5555555',
                    intss: '666666666'
                };
            }); 
    复制代码

    下面给出完整的代码。原理很简单,将搜索条件放在store的baseParams中,每次加载都赋值。

    只是需要强制赋值,因为默认的pagetoolbar只会把start、limit、page、sort、dir传递给store

    复制代码
    var store = new Ext.data.Store({  
           pageSize: GridPageSize,  
           model: 'Master',  
           autoLoad: false,   
           proxy: {  
               type: 'ajax',  
               url: '/master/GetMasterData',  
               reader: {  
                   type: 'json',  
                   root: 'data',  
                   totalProperty: 'totalCount'  
               }  
           },  
           fields: [  
               { name: 'Id' },  
               { name: 'Master_Name' }  
               
           //排序  
           sorters: [{  
               property: 'Master_Name',  
               direction: 'DESC'  
           }]   
            
       });  
    store.on('beforeload', function (store, options) {  
            var new_params = { name: Ext.getCmp('search').getValue() };  
            Ext.apply(store.proxy.extraParams, new_params);  
            // alert('beforeload');  
        });  
    store.load({  
           params: { start: 0, limit: GridPageSize }  
       })  
    复制代码

     

    收藏
    关注
    评论
     
    分类: Extjs
  • 相关阅读:
    [题解]小B的询问-莫队水题
    [学习笔记]莫队学习笔记[未完待续]
    ffmpeg设置超时时间
    python signal
    pydantic库使用文档
    rtmp及直播流相关资料
    ffmpeg 将视频转换成m3u8视频
    nginx stop失败问题
    linux使用ssh远程登录服务器
    解决Fcitx输入法文字候选无前端问题
  • 原文地址:https://www.cnblogs.com/Leo_wl/p/3255721.html
Copyright © 2011-2022 走看看