Extjs 项目中常用的小技巧,也许你用得着(5)--设置 Ext.data.Store 传参的请求方式

时间:2022-09-11 20:38:44

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

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

var resultsPanel = Ext.create('Ext.panel.Panel', {
title: 'Results',
width: 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 项目中常用的小技巧,也许你用得着(5)--设置 Ext.data.Store 传参的请求方式的更多相关文章

  1. Extjs 项目中常用的小技巧,也许你用得着(2)

    接着来,也是刚刚遇到的 panel怎么进行收缩 collapsible: true, 这会panel就会出现这个 点这个就可以收缩了 panel怎么随便拉伸,也就是让那个小黑三角出现 split: t ...

  2. Extjs 项目中常用的小技巧,也许你用得着(1)

    我在项目中遇到的一些知识点: 1.在GridPanel中显示图片,效果 对应的代码实现 { text: '是否启用', width: 80, // xtype: 'checkcolumn', data ...

  3. Extjs 项目中常用的小技巧,也许你用得着(3)

    几天没写了,接着继续, 1.怎么获取表单是否验证通过: form.isValid()//通过验证为true 2.怎样隐藏列,并可勾选: hidden: true, 如果是动态隐藏的话: grid.ge ...

  4. Extjs 项目中常用的小技巧,也许你用得着(4)---Extjs 中的cookie设置

    1.ExtJs设置cookie两种方式 其一:设置cookie如下 saveacct=isForm.getForm().findField('itemselector').getValue(); Ex ...

  5. ES6中常用的小技巧,用了事半功倍哦

    ES6中常用的小技巧,如果能在实际项目中能使用到,必定事半功倍: 1. 强制要求参数 ES6提供了默认参数值机制,允许你为参数设置默认值,防止在函数被调用时没有传入这些参数. 在下面的例子中,我们写了 ...

  6. vue 项目中实用的小技巧

    # 在Vue 项目中引入Bootstrap 有时在vue项目中会根据需求引入Bootstrap,而Bootstrap又是依赖于jQuery的,在使用npm按照时,可能会出现一系列的错误 1.安装jQu ...

  7. JS开发中常用的小技巧

    1.获取指定范围内的随机数 1 2 3 function getRadomNum(min,max){     return  Math.floor(Math.random() * (max - min ...

  8. MSSQL工作中常用的小技巧

    大概看了一下有接近二十天自己没有写博客了,一来是因为国庆之前公司工作总会比较繁杂一点,国庆自己也需要休息,二来是因为学习一些新的东西,公司写了一天SQL回家看了看以前的笔记,感觉还挺不错,贴出来供大家 ...

  9. 前端日常工作中常用开发小技巧 ---JavaScript

    1.格式化金钱值 const ThousandNum = num => num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "," ...

随机推荐

  1. 怎样把win7系统下的屏幕设置成护眼的非常柔和的豆沙绿色?

    经常面对电脑会导致眼睛过度疲劳,白色对眼睛的刺激是最大的,所以,最好不要用白色做电脑背景色 设置方法如下: 在桌面点右键选"个性化",接着点主窗口底部的"窗口颜色&quo ...

  2. MapleSim助力长臂挖掘机建模问题解决

    1.问题描述 一家机械零部件设计公司需要一个挖掘机模型,验证他们的零部件是否匹配完整的挖掘机系统.由于他们是一个零部件供应商,公司没有足够的资源和研发人员使用传统的工具创建一个完整系统的详细模型.然而 ...

  3. php反射

    反射 //反射查找对象方法所在的文件名.$n_func = new ReflectionMethod($obj,$function);$filepath = $n_func->getFileNa ...

  4. mac安装mongodb

    一,安装方法1 ,下载mongodb 1,官网下载mongodb程序 https://www.mongodb.org/downloads#production​ 2,解压后启动mongodb服务 下载 ...

  5. scrollba美化

    1.overflow内容溢出时的设置(设定被设定对象是否显示滚动条)    overflow-x水平方向内容溢出时的设置    overflow-y垂直方向内容溢出时的设置    以上三个属性设置的值 ...

  6. ASP.NET伪静态 UrlRewrite(Url重写) 实现和配置

    核心提示:大家一定经常在网络上看到很多网站的地址后缀都是用XX.HTML或者XX.ASPX等类似静态文件的标示来操作的吧,那么大家有怀疑过他真的是一个一个的静态生成的文件么,静态文件的生成的优缺有好有 ...

  7. hdu 4308 Saving Princess claire_

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4308 Saving Princess claire_ Description Princess cla ...

  8. Event Handling in Spring

    Spring内置的event有 1.ContextRefreshedEvent This event is published when the ApplicationContext is eithe ...

  9. UISearchDisplayController隐藏navigationBar需注意

    不能调用self.navigationController.navigationBar.hidden = YES: 调用此代码的话,你隐藏了navigationBar搜索展示控制器就拿不到导航条:就会 ...

  10. YII中表单验证

    关于表单的验证有三种: 1.yii的客户端验证 2.yii的服务器端验证 3.yii的ajax验证 例如: 1.在表单对应的模型中定义一个rules方法(该方添加后,在表单提交时,将自动被调用) pu ...