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

ExtJS扩展(一)

/**
 * @author howl
 * @start 2012-9-18
 * @end ...
 */

/**
* Quick get the object
* @param id    ModuleID
* @return Object   Module Object
*/
var $ = function(id){
 var obj = null;
 if(id){
  obj = Ext.getCmp(id);
 }
 return obj;
}

/**
* Get Grid's Store Object
* @param gridid  Grid Object ID
* @return Store  Grid's Store
*/
var $s = function(gridId){
 var obj = null;
 if($(gridId)){
  obj = $(gridId).getStore;
 }
 return obj;
}

/**
* Get Grid's PagingToolbar Object
*@param gridid   Grid's Object ID
* @return PagingToolbar Grid's PagingToolbar Object
*/
var $p = function(gridid){
 var bar = null;
 if($(gridid)){
  bar = $(gridid).getBottomToolbar();
 }
 return bar;
}

/**
 * change Records Get Grid's Record data which been updated or added
 *
 * @param gridid Grid ID
 * @return Record[] Grid's Collection object
 */
var $crs = function(gridid){
 var sels=[];
 if($(gridid)){
  var s = $s(gridid);
  sels =s.getModifierRecords();
 }
 return sels;
}

/**
 * Get the grid's first selected record,return Null while you didn't select
 * @param gridid Grid Object ID
 * @Return Record Object
 */
var sel = function(gridid){
 var sel = null;
 if($(gridid)){
  sel = $(gridid).getSelectionModel().getSelected();
 }
 return sel;
}

/**
 * Get the tree's selected node,return null while you didn't select
 * @param treeid Tree Object ID
 *
 * @return Tree Node Object
 */
var $node = function(treeid){
 var sel = null;
 if($(treeid)){
  sel = $(treeid).getSelectionModel().getSelectedNode();
 }
 return sel;
}

/**
 *Get the Grid's all record data,return Null if you didn't select
 * @param gridid Grid Object id
 *
 * @return Record[] Grid's collection obeject
 */
var $sels = function(gridid){
 var sels = null;
 if($(gridid)){
  sels = $(gridid).getSelectionModel().getSelections();
 }
 return sels;
}

/**
 * Get the grid's Store baseParams parameter and Paging parameter
 *
 * @param gridid
 *
 * @return Object  Filter parameter
 */
var $params = function(gridid){
 var params = {};
 if($(gridid)){
  param = Ext.apply(params,Ext.apply({
   start : $p(gridid).cursor,
   limit : $p(gridid).pageSize
  },$s(grid).baseParams))
 }
}

/**
 * Get page navigation's Paging parameter
 *
 * @param panelid
 *
 * @return Object  Filter parameter
 *
 */
var $barParams = function(panelid){
 var params = {};
 if($(panelid)){
  params = Ext.apply(params,{
   start : $p(panelid).cursor,
   limit : $p(panelid).pageSize
  })
 }
 return params;
}

/**
 * The Record do some override
 */
Ext.override(Ext.data.Record, {
   rowstatus : ""
  })

/**
 * Hide and Show Panel
 * @param  status  Panel status
 */
function hideShowPanel(status){
 if(parent && parent.$("west-panel") && parent.$("north-panel"))