gridpanel动态加载数据的实例代码


Posted in Javascript onJuly 18, 2013
<script type='text/javascript'>
function editEsOrder(options,success,response){
if (success){
var tagModelManager_maxOrderIdJson=Ext.util.JSON.decode(response.responseText);
var orderValue = tagModelManager_maxOrderIdJson.maxOrderId ;
Ext.getCmp('esorder').setValue(orderValue) ;
}
}
var tagModelManager_toolBar=new Ext.Toolbar({
items:[
{id:'tagModel_Save',text:'添加',iconCls:'add',handler:tagModel_Save}
,'-',
{id:'tagModel_dropSelected',text:'删除',iconCls:'remove',handler:tagModel_dropSelected}
]});
new Ext.grid.GridPanel({
id:'tagModelManager_tagModelGrid',
autoScroll:true,  store:new Ext.data.Store(),
cm:new Ext.grid.ColumnModel([new Ext.grid.RowNumberer()]),
sm:new Ext.grid.CheckboxSelectionModel(),
renderTo:'tagModelManager_tagModelDiv',
        width:Ext.getCmp('TagModel_win').getSize().width-16,
        height:Ext.getCmp('TagModel_win').getSize().height-35,
hideHeaders :false,
loadMask:{msg:'正在加载数据,请稍候....'},
collapsible : true,
collapsed : false,
bbar:new Ext.PagingToolbar({
id:'tagModelManager_tagModelPagingBar',
pageSize:getComboValue(),
store:new Ext.data.Store(),
displayInfo:true
}),
tbar:tagModelManager_toolBar
});
Ext.getCmp('tagModelManager_tagModelGrid').render() ;
Ext.getCmp('tagModelManager_tagModelGrid').on('rowdblclick', tagModelSelectRowDblClickEvent);
function tagModelSelectRowDblClickEvent(selectionModel, rowIndex, selectedRecord) {
  var selectedRows = Ext.getCmp('tagModelManager_tagModelGrid').getSelectionModel().getSelections();
      var row=selectedRows[0];   
      tagModel_SaveOrEdit('edit',row);
}
function tagModel_Save() {
      tagModel_SaveOrEdit('save');
}
function tagModelList_search() {
  Ext.Ajax.request({
  url:'editTagModel.html?method=getParams',
   callback:getSearchList
   });
}
function getSearchList(options,success,response) {
if (success){
var tagModelManager_json=Ext.util.JSON.decode(response.responseText);
tagModelManager_tagModelGridTitle = tagModelManager_json.tagModelManager_tagModelGridTitle;
var record = tagModelManager_json.record ;
var tagModelManager_tagModelColumnModels = tagModelManager_json.tagModelManager_tagModelColumnModels ;
        var tagModelManager_tagModelColumnModel=new Ext.grid.ColumnModel(Ext.util.JSON.decode("["+"new Ext.grid.RowNumberer()"+","+"new Ext.grid.CheckboxSelectionModel()"+","+tagModelManager_tagModelColumnModels+"]"));
tagModelManager_tagModelColumnModel.defaultSortable=true;
var strucutreModelManager_tagModelDataStore = new Ext.data.Store({
         baseParams: { tagModelKeyword : Ext.getCmp('tagModelManager_search_button').el.dom.value.trim() },
proxy:new Ext.data.HttpProxy({
url:'editTagModel.html?method=getTagModelDataList'
}),
reader:new Ext.data.JsonReader({
totalProperty:'resultSize',root:'tagModelList'},Ext.util.JSON.decode(record))  });
Ext.getCmp('tagModelManager_tagModelPagingBar').bind(strucutreModelManager_tagModelDataStore);
strucutreModelManager_tagModelDataStore.load({params:{start:0,limit:getComboValue()}}) ;
Ext.getCmp('tagModelManager_tagModelGrid').setTitle(tagModelManager_tagModelGridTitle) ;
Ext.getCmp('tagModelManager_tagModelGrid').reconfigure(strucutreModelManager_tagModelDataStore,tagModelManager_tagModelColumnModel);
Ext.getCmp('tagModelManager_tagModelGrid').expand(false) ;
}
}
function tagModelList_all(){
Ext.Ajax.request({
url:'editTagModel.html?method=getParams',
callback:getTagModel
});
}
function getTagModel(options,success,response){
if (success){
var tagModelManager_json=Ext.util.JSON.decode(response.responseText);
tagModelManager_tagModelGridTitle = tagModelManager_json.tagModelManager_tagModelGridTitle;
var record = tagModelManager_json.record ;
var tagModelManager_tagModelColumnModels = tagModelManager_json.tagModelManager_tagModelColumnModels ;
        var tagModelManager_tagModelColumnModel=new Ext.grid.ColumnModel(Ext.util.JSON.decode("["+"new Ext.grid.RowNumberer()"+","+"new Ext.grid.CheckboxSelectionModel()"+","+tagModelManager_tagModelColumnModels+"]"));
tagModelManager_tagModelColumnModel.defaultSortable=true;
var strucutreModelManager_tagModelDataStore = new Ext.data.Store({
proxy:new Ext.data.HttpProxy({
url:'editTagModel.html?method=getTagModelDataList'
}),
reader:new Ext.data.JsonReader({
totalProperty:'resultSize',root:'tagModelList'},Ext.util.JSON.decode(record))  });
Ext.getCmp('tagModelManager_tagModelPagingBar').bind(strucutreModelManager_tagModelDataStore);
strucutreModelManager_tagModelDataStore.load({params:{start:0,limit:getComboValue()}}) ;
Ext.getCmp('tagModelManager_tagModelGrid').reconfigure(strucutreModelManager_tagModelDataStore,tagModelManager_tagModelColumnModel);
Ext.getCmp('tagModelManager_tagModelGrid').expand(false) ;
}
}
Ext.Ajax.request({
url:'editTagModel.html?method=getParams',
callback:getTagModel
});
</script>
    public void getTagModelDataList(ActionMapping mapping, ActionForm actionform,HttpServletRequest request, HttpServletResponse response){
    ITagModelManager tagmgr = this.getPkgServer().getDriver().getOperateServer().getTagModelManager() ;
    List<HashMap<String,String>> models = new ArrayList<HashMap<String,String>>();
    String tagModelKeyword = request.getParameter("tagModelKeyword");
    List<EssTagModel> tagModels ;
    tagModels =  tagmgr.getEssTagModels() ;
    int resultSize = 0 ;
    if (null != tagModels && !tagModels.isEmpty()){
    //数据分页显示
    resultSize = tagModels.size() ;
    String start = request.getParameter("start") ;
String perPage = request.getParameter("limit") ;
String esType ="";
if (null != start && null != perPage){
int fromIdx = Integer.parseInt(start);
int per =  Integer.parseInt(perPage);
int toIdx = fromIdx + per ;
if (toIdx  > resultSize) toIdx = resultSize ;
tagModels = tagModels.subList(fromIdx,toIdx) ;
}
    for(EssTagModel etm : tagModels){
    HashMap<String,String> map = new HashMap<String, String>();
    map.put("id",   Long.toString(etm.getId())) ;
    map.put("esidentifier", etm.getEsidentifier()) ;
    map.put("estype", etm.getEstype()) ;
    map.put("esdescription", etm.getEsdescription()) ;
    map.put("esorder", Long.toString(etm.getEsorder())) ;
    map.put("metadata", etm.getMetadata()) ;
    models.add(map) ;
    }
    }
    JSONObject json = new JSONObject();
    JSONArray ary = new JSONArray(models);
    json.put("tagModelList", ary);
json.put("resultSize",resultSize);
    writeJson(response, json.toString()) ;
    }
public void getParams(ActionMapping mapping, ActionForm actionform,HttpServletRequest request, HttpServletResponse response){
LinkedHashMap<String,String> tags = new LinkedHashMap<String,String>() ;
tags.put("id", "id") ;
tags.put("esidentifier", "字段") ;
tags.put("estype", "类型") ;
tags.put("esdescription", "描述") ;
tags.put("esorder", "顺序") ;
tags.put("metadata", "元数据") ;
tags.put("esisnull", "是否为必填项") ;
tags.put("eslength", "字段长度") ;
tags.put("esdotlength", "小数点位数") ;
tags.put("esissystem", "是否为系统字段") ;
JSONObject json = new JSONObject();
json.put("record", getJsonRecord(tags)) ;
json.put("tagModelManager_tagModelColumnModels", getJsonColumnModel(tags)) ;
writeJson(response,json.toString());
}
Javascript 相关文章推荐
浅析XMLHttpRequest的缓存问题
Dec 13 Javascript
JS+CSS实现弹出全屏灰黑色透明遮罩效果的方法
Dec 20 Javascript
jQuery CSS3相结合实现时钟插件
Jan 08 Javascript
JavaScript代码性能优化总结篇
May 15 Javascript
AngularJS实践之使用NgModelController进行数据绑定
Oct 08 Javascript
基于bootstrap-datetimepicker.js不支持IE8的快速解决方法
Nov 07 Javascript
微信小程序实现传参数的几种方法示例
Jan 10 Javascript
JavaScript创建对象方法实例小结
Sep 03 Javascript
js监听html页面的上下滚动事件方法
Sep 11 Javascript
vue 自定义右键样式的实例代码
Nov 06 Javascript
vue video和vue-video-player实现视频铺满教程
Oct 30 Javascript
原生jQuery实现只显示年份下拉框
Dec 24 jQuery
javaScript NameSpace 简单说明介绍
Jul 18 #Javascript
JS获取鼠标坐标的实例方法
Jul 18 #Javascript
非常好用的JsonToString 方法 简单实例
Jul 18 #Javascript
转义字符(\)对JavaScript中JSON.parse的影响概述
Jul 17 #Javascript
JS随机生成不重复数据的实例方法
Jul 17 #Javascript
Javascript和HTML5利用canvas构建Web五子棋游戏实现算法
Jul 17 #Javascript
javascript和HTML5利用canvas构建猜牌游戏实现算法
Jul 17 #Javascript
You might like
thinkPHP5.0框架命名空间详解
2017/03/18 PHP
phpcms实现验证码替换及phpcms实现全站搜索功能教程详解
2017/12/13 PHP
javascript 框架小结 个人工作经验
2009/06/13 Javascript
Underscore.js 的模板功能介绍与应用
2012/12/24 Javascript
基于JavaScript实现继承机制之构造函数+原型链混合方式的使用详解
2013/05/07 Javascript
js获取电脑分辨率的思路及操作
2013/11/22 Javascript
javascript几个易错点记录
2014/11/26 Javascript
Node.js如何自动审核团队的代码
2016/07/20 Javascript
js实现控制textarea输入字符串的个数,鼠标按下抬起判断输入字符数
2016/10/25 Javascript
正则表达式基本语法及表单验证操作详解【基于JS】
2017/04/07 Javascript
jQuery插件FusionCharts绘制的2D条状图效果【附demo源码】
2017/05/13 jQuery
vue.js语法及常用指令
2017/10/29 Javascript
js微信分享接口调用详解
2019/07/23 Javascript
[05:43]VG.R战队教练Mikasa专访:为目标从未停止战斗
2016/08/02 DOTA
linux 下实现python多版本安装实践
2014/11/18 Python
python好玩的项目—色情图片识别代码分享
2017/11/07 Python
python 寻找优化使成本函数最小的最优解的方法
2017/12/28 Python
浅谈numpy库的常用基本操作方法
2018/01/09 Python
python实时监控cpu小工具
2018/06/21 Python
Python Pandas批量读取csv文件到dataframe的方法
2018/10/08 Python
Django的models模型的具体使用
2019/07/15 Python
python通过nmap扫描在线设备并尝试AAA登录(实例代码)
2019/12/30 Python
TensorFlow通过文件名/文件夹名获取标签,并加入队列的实现
2020/02/17 Python
opencv python在视屏上截图功能的实现
2020/03/05 Python
css3截图_动力节点Java学院整理
2017/07/11 HTML / CSS
CSS Grid布局教程之浏览器开启CSS Grid Layout汇总
2014/12/30 HTML / CSS
高校学生干部的自我评价分享
2013/11/04 职场文书
给儿子的表扬信
2014/01/15 职场文书
数学系个人求职信范文
2014/01/30 职场文书
调查研究项目计划书
2014/04/29 职场文书
法定代表人身份证明书
2014/09/10 职场文书
员工手册董事长致辞
2015/07/29 职场文书
你真的了解redis为什么要提供pipeline功能
2021/06/22 Redis
css中z-index: 0和z-index: auto的区别
2021/08/23 HTML / CSS
基于Python实现对比Exce的工具
2022/04/07 Python
搭建zabbix监控以及邮件报警的超级详细教学
2022/07/15 Servers