Extjs 项目中常用的小技巧,也许你用得着(5)--设置 Ext.data.Store 传参的请求方式
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 传参的请求方式的更多相关文章
- Extjs 项目中常用的小技巧,也许你用得着(2)
接着来,也是刚刚遇到的 panel怎么进行收缩 collapsible: true, 这会panel就会出现这个 点这个就可以收缩了 panel怎么随便拉伸,也就是让那个小黑三角出现 split: t ...
- Extjs 项目中常用的小技巧,也许你用得着(1)
我在项目中遇到的一些知识点: 1.在GridPanel中显示图片,效果 对应的代码实现 { text: '是否启用', width: 80, // xtype: 'checkcolumn', data ...
- Extjs 项目中常用的小技巧,也许你用得着(3)
几天没写了,接着继续, 1.怎么获取表单是否验证通过: form.isValid()//通过验证为true 2.怎样隐藏列,并可勾选: hidden: true, 如果是动态隐藏的话: grid.ge ...
- Extjs 项目中常用的小技巧,也许你用得着(4)---Extjs 中的cookie设置
1.ExtJs设置cookie两种方式 其一:设置cookie如下 saveacct=isForm.getForm().findField('itemselector').getValue(); Ex ...
- ES6中常用的小技巧,用了事半功倍哦
ES6中常用的小技巧,如果能在实际项目中能使用到,必定事半功倍: 1. 强制要求参数 ES6提供了默认参数值机制,允许你为参数设置默认值,防止在函数被调用时没有传入这些参数. 在下面的例子中,我们写了 ...
- vue 项目中实用的小技巧
# 在Vue 项目中引入Bootstrap 有时在vue项目中会根据需求引入Bootstrap,而Bootstrap又是依赖于jQuery的,在使用npm按照时,可能会出现一系列的错误 1.安装jQu ...
- JS开发中常用的小技巧
1.获取指定范围内的随机数 1 2 3 function getRadomNum(min,max){ return Math.floor(Math.random() * (max - min ...
- MSSQL工作中常用的小技巧
大概看了一下有接近二十天自己没有写博客了,一来是因为国庆之前公司工作总会比较繁杂一点,国庆自己也需要休息,二来是因为学习一些新的东西,公司写了一天SQL回家看了看以前的笔记,感觉还挺不错,贴出来供大家 ...
- 前端日常工作中常用开发小技巧 ---JavaScript
1.格式化金钱值 const ThousandNum = num => num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "," ...
随机推荐
- 定时任务 Wpf.Quartz.Demo.3
先把全部源码上传,只是一个Demo,希望大家指点一下不足之处,见本文底部. 1.设置界面 2.详情页面 好了,现在慢慢叙述里面的一些方法. 3.实现拷贝的方法: (1) public static v ...
- Spring IOC 容器源码分析系列文章导读
1. 简介 Spring 是一个轻量级的企业级应用开发框架,于 2004 年由 Rod Johnson 发布了 1.0 版本.经过十几年的迭代,现在的 Spring 框架已经非常成熟了.Spring ...
- Android开发教程 - 使用Data Binding(三)在Activity中的使用
本系列目录 使用Data Binding(一)介绍 使用Data Binding(二)集成与配置 使用Data Binding(三)在Activity中的使用 使用Data Binding(四)在Fr ...
- 如何查看 Ubuntu下已安装包版本号
原文链接:https://www.cnblogs.com/the-tops/p/8350662.html 一个软件工具叫做apt-show-versions,通过apt-get安装: $sudo ap ...
- [JavaScript] 的异步编程之手写一个Gernerator的例子
<html> <head> <meta charset="UTF-8"> <title>Generator Demo</tit ...
- 开发创建XMPP“发布订阅”扩展(xmpp pubsub extend)
发布订阅(PubSub)是一个功能强大的XMPP协议扩展.用户订阅一个项目(在xmpp中叫做node),得到通知时,也即当事项节点更新时.xmpp服务器通知用户(通过message格式). 节点类型: ...
- [Leetcode]315.计算右侧小于当前元素的个数 (6种方法)
链接 给定一个整数数组 nums,按要求返回一个新数组 counts.数组 counts 有该性质: counts[i] 的值是 nums[i] 右侧小于 nums[i] 的元素的数量. 示例: 输 ...
- Git使用、Git配置、Git提交代码、Git上传
非教程,只是自己的一个简单笔记.建议没有入门的朋友,直接看git的官方help文档: https://help.github.com/articles/set-up-git 1.注册一个git账号,超 ...
- java中连接各种数据的方法
1.oraclethin驱动连接字符串:jdbc:oracle:thin:用户名/密码@localhost:1521:cake驱动类:oracle.jdbc.driver.OracleDriver 2 ...
- (转)【深度长文】循序渐进解读Oracle AWR性能分析报告
原文:https://dbaplus.cn/news-10-734-1.html https://blog.csdn.net/defonds/article/details/52958303 作者介绍 ...