EXTJS 4.2 资料 Grid嵌套
如图:
var ParentContCateId = 0;
var start = 0;
var limit = 20;
DistributionPointForm = function () {
Ext.define('Warehouse', {
extend: 'Ext.data.Model',
fields: [
{ name: 'StoreId' },
{ name: 'StoreCode' },
{ name: 'StoreName', type: 'string' },
{ name: 'Address', type: 'string' },
{ name: 'PostCode', type: 'string' },
{ name: 'AreaId', type: 'string' },
{ name: 'ManufacturerId', type: 'string' },
{ name: 'ManagerMethod', type: 'string' },
{ name: 'Contactor', type: 'string' },
{ name: 'ContactInfo', type: 'string' },
{ name: 'City', type: 'string' },
//{ name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia' }, ]
});
var mainStore = Ext.create('Ext.data.Store', {
model: 'Warehouse',//这个地方user不是一个对象,而是一个类
pageSize: limit, //页容量20条数据
//是否在服务端排序 (true的话,在客户端就不能排序)
remoteSort: false,
remoteFilter: true,
method: 'POST',
proxy: {//代理
type: 'ajax',
url: '/UI/HttpHandlerData/StoreManagement/DistributionPoint.ashx?operation=SearchInfoWarehouse',
extraParams: {
start: start,
limit: limit
},
reader: {
type: 'json', //返回数据类型为json格式
root: 'Table', //根节点
totalProperty: 'result' //数据总条数
}
},
sorters: [{
//排序字段。
property: 'StoreId',
//排序类型,默认为 ASC
direction: 'desc'
}],
autoLoad: true //即时加载数据
}); function displayInnerGrid(renderId) {
//Model for the inside grid store
Ext.define('DistributionPoint', {
extend: 'Ext.data.Model',
fields: [
{ name: 'DPId' },
{ name: 'CompanyId' },
{ name: 'CompanyName' },
{ name: 'StoreId' },
{ name: 'DPCode' },
{ name: 'DPName' },
{ name: 'LocationId' },
{ name: 'LocationName' },
{ name: 'Leadtime' },
{ name: 'CompanyTypeName' },
{ name: 'CompanyTypeId' }
]
}); var insideGridStore = Ext.create('Ext.data.Store', {
model: 'DistributionPoint',//这个地方DistributionPoint不是一个对象,而是一个类
pageSize: limit, //页容量20条数据
remoteSort: false,
remoteFilter: true,
method: 'POST',
proxy: {//代理
type: 'ajax',
url: '/UI/HttpHandlerData/StoreManagement/DistributionPoint.ashx?operation=SearchInfoDistributionPoint',
extraParams: {
start: start,
limit: limit,
StoreId: renderId //传入StoreId进行过滤
},
reader: {
type: 'json', //返回数据类型为json格式
root: 'Table', //根节点
totalProperty: 'result' //数据总条数
}
},
groupField: 'CompanyTypeName', //确定哪一项分组
sorters: [{
//排序字段。
property: 'DPId',
//排序类型,默认为 ASC
direction: 'ASC'
}],
autoLoad: true //即时加载数据
}); innerGrid = Ext.create('Ext.grid.Panel', {
title: '门店信息列表',
store: insideGridStore,
forceFit: true,//填充grid宽度
selModel: {
selType: 'cellmodel'
},
columns: [
{ header: "DPId", dataIndex: 'DPId', width: 100, hidden: true },
{ header: "StoreId", dataIndex: 'StoreId', width: 200, hidden: true },
{ header: "门店编码", dataIndex: 'DPCode', width: 100 },
{ header: "门店名称", dataIndex: 'DPName', width: 200 },
{ header: "所在地区", dataIndex: 'LocationName', width: 200 },
{ header: "交付周期", dataIndex: 'Leadtime', width: 100 },
{ header: "厂商名称", dataIndex: 'CompanyName', width: 200 },
{ header: "厂商类型", dataIndex: 'CompanyTypeId', width: 100 },
{ header: "门店类型", dataIndex: 'CompanyTypeName', width: 100 },
{
header: '操作', align: 'left', width: 100, renderer:
function (v, nv, v1) {
var Update = "<img src='/Resources/Images/16x16/blue16_020.gif'></img>" + '<a href="#" onClick="FunctionActionUpdate()">修改</a>';
var Delete = "<img src='/Resources/Images/16x16/blue16_013.gif'></img>" + '<a href="#" onClick="FunctionActionDelete()">删除</a>';
return Update + ' ' + Delete;
}
}
],
columnLines: true,
autoWidth: true,
autoHeight: true,
frame: false,
iconCls: 'icon-grid',
features: [{ ftype: 'grouping' }],
renderTo: renderId,
tbar: [
"->", {
xtype: 'button', icon: '/Resources/Images/16x16/blue16_002.gif', text: "添加",
handler: function () {
win.show();
win.setTitle('添加');
}
}]
}); innerGrid.getEl().swallowEvent([
'mousedown', 'mouseup', 'click',
'contextmenu', 'mouseover', 'mouseout',
'dblclick', 'mousemove'
]);
}
function destroyInnerGrid(record) {
var parent = document.getElementById(record.get('StoreId'));
var child = parent.firstChild;
while (child) {
child.parentNode.removeChild(child);
child = child.nextSibling;
}
}
Ext.define('MainGrid', {
extend: 'Ext.grid.Panel',
alias: 'widget.MainGrid',
store: mainStore,
forceFit: true,//填充grid宽度
stripeRows: true,
columns: [
{ header: "仓库id", dataIndex: 'StoreId', width: 200, hidden: true },
{ header: '序号', xtype: 'rownumberer', align: 'left', width: 100 },
{ header: "仓库编码", dataIndex: 'StoreCode', width: 200 },
{ header: "仓库名称", dataIndex: 'StoreName', width: 200 },
{ header: "所在城市", dataIndex: 'City', width: 200 },
],
autoWidth: true,
autoHeight: true,
selModel: {
selType: 'cellmodel'
},
plugins: [{
ptype: 'rowexpander',
rowBodyTpl: [
'<div id="{StoreId}">',
'</div>'
]
}],
collapsible: true,
animCollapse: false,
title: '仓库信息列表',
iconCls: 'icon-grid',
initComponent: function () {
var me = this;
this.callParent(arguments);
}
}); var mainGrid = new Ext.create('MainGrid'); mainGrid.view.on('expandBody', function (rowNode, record, expandRow, eOpts) {
displayInnerGrid(record.get('StoreId'));
}); mainGrid.view.on('collapsebody', function (rowNode, record, expandRow, eOpts) {
destroyInnerGrid(record);
}); mainGrid.setHeight(window.innerHeight);
mainGrid.setWidth(window.innerWidth);
Ext.EventManager.onWindowResize(function () {
mainGrid.setHeight(window.innerHeight);
mainGrid.setWidth(window.innerWidth);
}); //**************页面主体开始*****************
var tabpanel = Ext.createWidget('tabpanel', {
activeTab: 0, //指定默认的活动tab
height: '100%',
width: '100%',
minTabWidth: 115,
tabWidth: 135,
plain: true, //True表示tab候选栏上没有背景图片(默认为false)
enableTabScroll: true, //选项卡过多时,允许滚动
defaults: { autoScroll: true },
items: [{
id: "tab1",
title: '配送点设置',
icon: '/Resources/Images/16x16_Classic/20101204100142490_easyicon_cn_16.png',
items: mainGrid,
closable: true //这个tab可以被关闭
}, {
id: "tab2",
title: '配送点详情',
icon: '/Resources/Images/16x16_Classic/20101204100142490_easyicon_cn_16.png',
html: "这只是一个非常普通的Tab。",
items: [{ xtype: 'button', text: '按钮' }],
closable: true //这个tab可以被关闭
}]
});
//**************页面主体结束*****************
var panel = new Ext.Viewport({
border: false,
layout: 'border',
items: [
{
region: 'center',
border: false,
layout: 'fit',
items: tabpanel
}]
});
}
html:
<body>
<div>
<script type="text/javascript">
Ext.onReady(function () {
Ext.QuickTips.init();
DistributionPointForm();
});
</script>
</div>
</body>
EXTJS 4.2 资料 Grid嵌套的更多相关文章
- EXTJS 4.2 资料 控件之Grid 行编辑绑定下拉框,并点一次触发一次事件
主要代码: { header: '属性值', dataIndex: 'PropertyValueName', width: 130, editor: new Ext.form.field.ComboB ...
- EXTJS 4.2 资料 控件之Grid 添加行,编辑行,删除行
//SiteVariableConfigValue类,创立一个模型类 Ext.define("SiteVariableConfigValue", { extend: "E ...
- EXTJS 4.2 资料 控件之Grid Columns 列renderer 绑定事件
columns: [ { header: '序号', xtype: 'rownumberer', align: 'center', width: 100 }, { header: 'CompanyId ...
- EXTJS 4.2 资料 控件之Grid 那些事
最近在学习Extjs4.2 ,积累文章,看得不错,再此留年: //表格数据最起码有列.数据.转换原始数据这3项 Ext.onReady(function(){ //定义列 var columns = ...
- EXTJS 4.2 资料 控件之Grid 列鼠标悬停提示
columns: [ { header: }, { header: }, { header: , renderer: function (v, ctx, record) { ctx.tdAttr = ...
- ExtJS扩展:扩展grid
ExtJs的grid功能很强大,但是有时候觉得总是少那么一点点功能,我们就来扩展它,让它用起来更方便. 今天我们要扩展的是:根据记录的选择数量来禁用或启用grid toolbar上的某些按钮. 本文所 ...
- extjs动态树 动态grid 动态列
由于项目需要做一个动态的extjs树.列等等,简而言之,就是一个都是动态的加载功能, 自己琢磨了半天,查各种资料,弄了将近两个星期,终于做出来了 首先,想看表结构,我的这个功能需要主从两张表来支持 代 ...
- extjs学习(关于grid)
1.想要调整某一列在表格中的顺序,可以使用mapping(索引是从0开始的) var store = new Ext.data.ArrayStore({ data:data, fields:[ {na ...
- EXTJS 4.2 资料 控件之radiogroup 的用法
最近在EXTJS4.2开发项目,radiogroup的用法,主要是和grid之间的编辑功能:看了好多资料都不对,特此在这里备注记录 代码如下, 1.这是一段Win窗体上的两个单选按钮,设置单选按钮都是 ...
随机推荐
- 给jdk写注释系列之jdk1.6容器(8)-TreeSet&NavigableMap&NavigableSet源码解析
TreeSet是一个有序的Set集合. 既然是有序,那么它是靠什么来维持顺序的呢,回忆一下TreeMap中是怎么比较两个key大小的,是通过一个比较器Comparator对不对,不过遗憾的是,今天仍然 ...
- [改善Java代码]equals应该考虑null值的情景
建议46: equals应该考虑null值情景 继续上一建议的问题,我们解决了覆写equals的自反性问题,是不是就很完美了呢?再把main方法重构一下: public class Client { ...
- DAG的动态规划 (UVA 1025 A Spy in the Metro)
第一遍,刘汝佳提示+题解:回头再看!!! POINT: dp[time][sta]; 在time时刻在车站sta还需要最少等待多长时间: 终点的状态很确定必然是的 dp[T][N] = 0 ---即在 ...
- asp.net微信支付打通发货通知代码
上次遇到微信支付,发货接口的时候,官方的demo也没有提供相应的代码 ,因本人技术有限,百度 google 很久都没有asp.net 版本的,最后只好硬着头皮自己搞,没想到官方文档也是错的. 我这一步 ...
- android手机操作SD的使用方法
写入SD卡 package com.example.openfileproject; import java.io.File; import java.io.FileInputStream; impo ...
- c# 如何处理自定义消息
C#自定义消息通信往往采用事件驱动的方式实现,但有时候我们不得不采用操作系统的消息通信机制,例如在和底层语言开发的DLL交互时,是比较方便的.下面列举了一些实现方式,供大家参考:一.通过SendMes ...
- 暑假集训(5)第一弹——— Super Jumping! Jumping! Jumping!(hdu1087)
题意概括:在上次与娑殚的三次博弈中,你们都取得了胜利.便向娑殚提出要求,借助他的力量,传送到一个安全的地方. 你们的愿望达成了,不过,你和小A似乎失散了. 街上人来人往的特别热闹,每一个人的脸上都洋溢 ...
- [Guava学习笔记]Collections: 不可变集合, 新集合类型
我的技术博客经常被流氓网站恶意爬取转载.请移步原文:http://www.cnblogs.com/hamhog/p/3843386.html,享受整齐的排版.有效的链接.正确的代码缩进.更好的阅读体验 ...
- 《SELinux安全上下文的管理(含图)》RedHat6.3——步骤详细、条理清晰
1.为什么浏览器只识别/var/www/html下的文件? 2.为什么不识别别的目录下的index.html文件呢? 3.这里牵扯到身份证,先安装软件包. 4.打开selinux 5.建立一个新的目录 ...
- mapper配置
一:查询 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC &q ...