zoukankan      html  css  js  c++  java
  • 在ExtJS4.0中,加载Store前添加查询参数。

    在ExtJS4.0中,怎么添加其它参数来实现自动加载Model中数据时对数据的筛选呢。呵呵,下面有解了:

    grid.getStore().getProxy().extraParams = { operate: 'searchCase', 'type': searchType.getValue(), 'startDate': sDate, 'text': searchText.getValue() };

    部分代码(摘自《物证流转系统》):

     var grid = Ext.create("Ext.grid.Panel", {
                    store: Ext.data.StoreManager.lookup("caseStore"),
                    columns: {
                        items: [
                                { text: '案件编号', dataIndex: 'CaseId', hidden: true },
                                { text: '案件名称', dataIndex: 'CaseName',  200 },
                                { text: '案发时间', dataIndex: 'CaseTime', xtype: 'datecolumn', format: 'Y-m-d',  190, align: 'center' },
                                { text: '案发地点', dataIndex: 'CaseAddress',  300 },
                                { text: '单位编号', dataIndex: 'CaseAddress' },
                                { text: '现场勘查号', dataIndex: 'ExplorationNo',  150, align: 'center' }
                        ],
                        defaults: {}
                    },
                    forceFit: false,
                    enableLocking: true
                });
                var pagingToolbar = {
                    xtype: 'pagingtoolbar',
                    store: Ext.data.StoreManager.lookup("caseStore"),
                    displayInfo: true,
                    flex: 1
                }
    
                var searchStartTime = Ext.create('Ext.form.field.Date', {
                    flex: 3, maxValue: new Date(), format: 'Y-m-d',
                    emptyText: '起始案发日期...'
                });
                var searchEndTime = Ext.create('Ext.form.field.Date', {
                    flex: 3, maxValue: new Date(), format: 'Y-m-d',
                    emptyText: '终止案发日期...'
                });
    
                var searchType = Ext.create('Ext.form.ComboBox', {
                    labelWidth: 70,
                    store: Ext.data.StoreManager.lookup("searchTypeCaseStore"),
                    queryMode: 'local',
                    valueField: 'type',
                    displayField: 'name',
                    flex: 3,
                    labelAlign: 'right',
                    editable: false,
                    emptyText: '选择查找类型...'
                });
                var searchText = Ext.create('Ext.form.Text', {
                    flex: 4,
                    emptyText: '输入匹配值后按Enter键...',
                    listeners: {
                        specialkey: function (field, e) {
                            if (e.getKey() == e.ENTER) {
                                searchBtn.fireEvent("click");
                            }
                        }
                    }
                });
                var searchBtn = Ext.create('Ext.button.Button', {
                    text: '搜索',
                     80
                });
    
                var panel = Ext.create('Ext.panel.Panel', {
                    bodyPadding: 0,
                    layout: 'fit',
                    bbar: [pagingToolbar],
                    tbar: [searchStartTime, searchEndTime, searchType, searchText, searchBtn],
                    items: [grid],
                    collapseDirection: 'left'
                });
    
                //过滤处理
                searchBtn.on("click", function () {
                    if (!searchType.getValue()) { searchType.setValue("CaseName"); }
                    var sDate = searchStartTime.getValue();
                    var eDate = searchEndTime.getValue();
                    if (sDate) {
                        if (eDate) {
                            grid.getStore().getProxy().extraParams = { operate: 'searchCase', 'type': searchType.getValue(), 'startDate': sDate, 'endDate': eDate, 'text': searchText.getValue() };
                        } else {
                            grid.getStore().getProxy().extraParams = { operate: 'searchCase', 'type': searchType.getValue(), 'startDate': sDate, 'text': searchText.getValue() };
                        }
                    } else {
                        if (eDate) {
                            grid.getStore().getProxy().extraParams = { operate: 'searchCase', 'type': searchType.getValue(), 'endDate': eDate, 'text': searchText.getValue() };
                        } else {
                            grid.getStore().getProxy().extraParams = { operate: 'searchCase', 'type': searchType.getValue(), 'text': searchText.getValue() };
                        }
                    }
    
    
                    grid.getStore().load();
                });
    

      

  • 相关阅读:
    运营设计方法论
    使用 typescript ,提升 vue 项目的开发体验(2)
    PAT 1078. 字符串压缩与解压
    PAT 1077. 互评成绩计算
    PAT 1076. Wifi密码
    PAT 1075. 链表元素分类
    PAT 1074. 宇宙无敌加法器
    PAT 1073. 多选题常见计分法
    PAT 1072. 开学寄语
    PAT 1071. 小赌怡情
  • 原文地址:https://www.cnblogs.com/songxingzhu/p/3003493.html
Copyright © 2011-2022 走看看