Ext之自定义组件,之Render

阅读更多
/**
 * 数据字典 代码到名称的翻译
 * author zgl 2014-02-24
 * 
 * 【用法】
 * 定义   var cameraTypeRender = new  Ext.rtt.dictionary.RendererMultiple('com.rtt.emergency.resource.model.Carmera.typeId'); 
 * 
 * 使用   {
                header   : '类型', 
                width    : 50, 
                sortable : true, 
                dataIndex: 'typeId',
                align :'center',
                renderer:cameraTypeRender.renderer.createDelegate(cameraTypeRender)
            }
            
   【解释】 
   输入: 01,02
   输出: 水灾,火灾        
 */ 
Ext.rtt.dictionary.RendererMultiple = function(datatype){  
  	var storeObject = {};
	storeObject.autoDestroy = true;
	storeObject.autoLoad = true;
	storeObject.url = ContextPath + '/commplat/json_service.do';
	storeObject.root = 'root';
	var fields = 'id,name';
	var fieldsArr = fields.split(",");
	storeObject.fields = fieldsArr;
	//storeObject.fields=fields;
	
	var baseParams = {};
	baseParams.jsonlist = 'jsonlist';
	//add cyzhang 绕过session检查
	baseParams.bypass = 'true';
	baseParams.serviceClassName = 'com.rtt.platform.system.service.http.ListTypeServiceJSON';
	baseParams.serviceMethodName = 'getListTypes';
	baseParams.serviceParameters = 'type';
	baseParams.type = datatype;
	storeObject.baseParams = baseParams;
	Ext.rtt.dictionary.RendererMultiple.superclass.constructor.apply(this, arguments);
	
	this.store = new Ext.data.JsonStore(storeObject);
	var me1 = this;
	this.store.on("load", function(store, records, options ) {
		me1.fireEvent('load');	
			
		});
		
	this.store.on("loadexception", function(combobox, o, response, e) {
			var msgObj = Ext.decode(response.responseText);
			Ext.Msg.alert('错误', msgObj.msg);
		});
	//return this.store;
	//this.displayField = "dcName";
	//this.valueField = "code";
};

Ext.extend(Ext.rtt.dictionary.RendererMultiple, Ext.util.Observable,{ 	
  /**
   * 构造方法
   * @param config 配置信息
   */
  constructor: function(config){ 
    this.name = config.name;        
    this.addEvents({
          "load" : true,
          "loadexception" : true
      }); 
    //this.listeners = config.listeners;         
  },
  getStore :  function(){
    return this.store;
  },
  renderer :  function(v){
  	var displayText = '';
  	var vArray = v.split(',');
  	for(var i=0;i 
 













-

你可能感兴趣的:(ext,Render)