日期:2014-05-16  浏览次数:20367 次

ExtJs代码片段小结

1.ajax

var requestConfig = {
 url : '/storage/assay/assaycollectionsample!isRenewable.action',
 params : {ids : ids},
 callback : function(options,success, response) {
  if(success){
   var json =Ext.util.JSON.decode(response.responseText);
   if (json.success) { 
    tempThis.doUpdate();
   }else{
    Ext.ux.LevitationMsgBox.msg('提示',json.result,5);
   }
  }else{
   Ext.ux.LevitationMsgBox.msg('提示','网络超时,请求失败!',5);
  }
 }
}
Ext.Ajax.request(requestConfig);

Ext.Ajax.request({ 
 url : '/organperson/pmjt-organ-person-relation!saveRelation.action',
 params : {
      },
 success : function(response,options) {
 },
 failure : function(response,options) {
 }
});

?
2.保存进度条

//当出现弹出窗口,进度条消失 
Ext.MessageBox.show({
   title : "提示",
   msg : "数据保存中...",
   progress : true,
   width : 300,
   wait : true,
   closable : true
  });

?

3.JsonCinfig的使用

JsonConfig jsonConfig = new JsonConfig();
jsonConfig.setExcludes(new String[]{ "hibernateLazyInitializer", "localSellCarryCoal"});
jsonConfig.registerJsonValueProcessor(java.sql.Timestamp.class, new DateJsonValueProcessor("yyyy-MM-dd"));
for(LocalSellCarryCoalItem item:items){
 json.append(JSONSerializer.toJSON(item,jsonConfig).toString());

?
.......

4.Grid拖拽

listeners : {
    rowdblclick : function(grid, rowIndex, e) {
     var spList = grid.getStore().getAt(rowIndex).get("tisEffective");
     if (spList == "是") {
      grid.getStore().getAt(rowIndex)
        .set("tisEffective", "否");
     } else if (spList == "否") {
      grid.getStore().getAt(rowIndex)
        .set("tisEffective", "是");
     }
    },
    afterrender:function(){
     var thisGrid=this;
     //alert(thisGrid);
     /**//**  
         * 列表右键菜单  
         */  
              thisGrid.addListener('rowcontextmenu', rightClickFn);   
              var rightClick = new Ext.menu.Menu( {   
                 id : 'spotTSampleListGrid_rightClickCont',   
                 items : [ {   
                      id:'spotTSampleListGrid_reverseMenu',   
                      text : '翻转',
                      icon:'../publicresource/images/icons/anchor.png',
                      handler:thisGrid.reverse  
                 }, {   
                      id:'spotTSampleListGrid_removeMenu',   
                      text : '移除',
                      iconCls : "delete",
                      handler:thisGrid.remove  
                 }, {   
                      id:'spotTSampleListGrid_judgeMenu',   
                      text : '判定',
                      iconCls : "link",
                      handler:thisGrid.judge  
                 },'-', {   
                      id:'spotTSampleListGrid_helpMenu',   
                      text : '说明',
                      icon:'../publicresource/images/icons/tux.png',
                      handler:function(){
                       Ext.Msg.alert("说明","翻转:倒序排列当前批次的车号<br/>" +
                         "移除:移除当前批次的所有车号<br/>" +
                         "判定:计算判定区匹配度,展示结果<br/>");
                      }
                 }]   
             });   
             function rightClickFn(grid, rowIndex, e) {   
                  e.preventDefault();
                  thisGrid.rightClickRowIndex=rowIndex;
                  rightClick.showAt(e.getXY());   
             }; 
     /* 
      * esky
      * 添加拖拽排序
      */
     new Ext.dd.DropTarget(thisGrid.container, {
            ddGroup : 'GridDD',
            copy    : false,
            notifyDrop : function(dd, e, data) {
             var store=thisGrid.getStore();
                // 选中了多少行
                var rows = data.selections;
                // 拖动到第几行
                var index = dd.getDragData(e).rowIndex;
                if (typeof(index) == "undefined") {
                    return;
                }
                // 修改store