Ext.define('ZYMLZiYuanModel', { extend: 'Ext.data.Model', fields:[ 'TITLE','DATASOURCES','CREATDATE','AROUNDRESID','QUERYID','resourceclass'] }); var resourceid=$('#resMainInfoId').val(); var ZYMLZiYuanStore = new Ext.data.Store({ autoDestroy: true, pageSize: 10, model: 'ZYMLZiYuanModel', proxy: { type: 'ajax', url: '/res/queryaround/getResourceSetZBCX?resourceid='+resourceid, reader: { root: 'topics', totalProperty: 'totalCount' }, simpleSortMode: true }, remoteSort: true }); var formdata = {}; Ext.onReady(function () { Ext.state.Manager.setProvider(new Ext.state.CookieProvider()); Ext.tip.QuickTipManager.init(); Ext.Ajax.timeout = 900000; Ext.require([ 'Ext.ux.PagingToolbar' ]); Ext.create('Ext.grid.Panel', { id: 'gridexample', renderTo: 'grid', // height: 540, layout: 'fit', autoScroll: false, store: ZYMLZiYuanStore, stateful: false, stateId: 'ZYMLZiYuan-Grid', viewConfig: { forceFit: true, enableTextSelection: true //列表数据可复制 }, columns:[ { xtype: 'rownumberer', text: "序号", width: '5%', align: 'center' }, { text: "资源名称", dataIndex: 'TITLE', width: '30%', flex: 1, sortable: true, align: 'center', filter: { type: 'string' }, renderer: function (value, p, record) { var ziYuanId = record.getData()["AROUNDRESID"]; var tit = htmlEncodeByRegExp(value); return Ext.String.format( '{2}', ziYuanId, value, tit ); } }, { text: "资源类型", dataIndex: 'resourceclass', width: '15%', sortable: true, align: 'center', filter: { type: 'string' }, renderer: function (value, p, record) { var color = ""; if (value == "基础底图" || value == "三维影像") { color = "label-success"; } else if (value == "业务图层" || value == "接口服务") { color = "label-danger"; } else if (value == "空间分析") { color = "label-warning"; } else if (value == "专题地图" || value == "三维地形") { color = "label-pink"; } else if (value == "专题应用程序" || value == "数据文件") { color = "label-default"; } else if (value == "业务集成") { color = "label-info"; } else if (value == "文档数据" || value == "数据库表" || value == "三维模型") { color = "label-primary"; } return Ext.String.format( '{1}', color, value ); } }, { text: "数据来源", dataIndex: 'DATASOURCES', width: '30%', sortable: true, filter: { type: 'string' }, align: 'center' }, { text: "操作", dataIndex: 'AROUNDRESID', id: 'AROUNDRESID', width: '20%', sortable: true, align: 'center', filter: { type: 'string' }, renderer: function (value, p, record) { var queryId = record.getData()["QUERYID"]; return Ext.String.format( '', queryId ); } } ] , bbar: Ext.create('Ext.ux.PagingToolbar', { id: "Page", name: "Page", store: ZYMLZiYuanStore, displayInfo: true, firstText: "首页", prevText: "上一页", nextText: "下一页", lastText: "尾页", refreshText: '刷新', beforePageText: '第', afterPageText: '页,共 {0} 页', displayMsg: '显示 {0} - {1} 条,共 {2} 条', emptyMsg: "没有数据显示", items: [ { xtype: 'label', text: '' } ] }) }); ZYMLZiYuanStore.on('beforeload', function () { //GetSearchWhere("SearchForm"); ZYMLZiYuanStore.proxy.extraParams = []; Ext.apply(ZYMLZiYuanStore.proxy.extraParams, formdata); }); ZYMLZiYuanStore.on('load', function (store, records, successful, eOpts) { }); ZYMLZiYuanStore.load(); //添加resize监听防止切换tab或者收起左栏导致grid不自适应宽度 $(window).resize(function () { Ext.getCmp('gridexample').doLayout();//panel重新布局 }); }); //查询事件 function Search() { Ext.getCmp('gridexample').dockedItems.items[1].store.currentPage = 1; ZYMLZiYuanStore.load(); } //添加资源按钮 function addMainInfo() { layer.open({ type: 2, title: '添加资源', id: 'ZiYuanKZ', shadeClose: true, shade: 0.7, maxmin: false, //开启最大化最小化按钮 area: ['800px', '550px'], content: 'resource_select?flag=zbcx&resourceid=' + resourceid }); } function delZiYuanGuanLian(objectid) { if (confirm("确定删除吗?")) { $.ajax({ url: '/res/queryaround/deleteByPrimaryKey?queryid='+objectid, type: 'get', dataType: 'text', success: function (data) { if (data == "1") { alert('删除成功'); ZYMLZiYuanStore.loadPage(1);//重新查询并跳转到第一页 winparpostMsg(); } else { alert('删除失败'); } } }) } } //跨域回调 function winparpostMsg() { if(window.parent.opener) { window.parent.opener.postMessage(true, "*"); } } //打开查看资源信息窗口 function OpenZiYuan(id) { var url = "/res/ZiYuan/ZiYuanBaseInfo?resourceid=" + id; window.open(url, '_blank', 'location=yes,scrollbars=yes,status=yes'); }