当前位置: 代码迷 >> Web前端 >> Ext.ux.grid.CheckColumn 增添 afteredit 事件
  详细解决方案

Ext.ux.grid.CheckColumn 增添 afteredit 事件

热度:1031   发布时间:2012-11-05 09:35:12.0
Ext.ux.grid.CheckColumn 添加 afteredit 事件

最近做一个手机充值的后台想使用ext做ui,结果发现官方的CheckColumn没有afteredit事件,自己研究了改了下

CheckColumn.js

Ext.ux.grid.CheckColumn = Ext.extend(Ext.grid.Column, {

    /**
     * @private
     * Process and refire events routed from the GridView's processEvent method.
     */
    processEvent : function(name, e, grid, rowIndex, colIndex){
        if (name == 'mousedown') {
            var record = grid.store.getAt(rowIndex);
            record.set(this.dataIndex, !record.data[this.dataIndex]);
            this.fireEvent("afteredit", {id:record.data['id'],column:this.dataIndex,value:record.data[this.dataIndex]}); //fire
            return false; // Cancel row selection.
        } else {
            return Ext.grid.ActionColumn.superclass.processEvent.apply(this, arguments);
        }
    },


    renderer : function(v, p, record){
        p.css += ' x-grid3-check-col-td'; 
        return String.format('<div class="x-grid3-check-col{0}">&#160;</div>', v ? '-on' : '');
    },

    // Deprecate use as a plugin. Remove in 4.0
    init: Ext.emptyFn
});

// register ptype. Deprecate. Remove in 4.0
Ext.preg('checkcolumn', Ext.ux.grid.CheckColumn);

// backwards compat. Remove in 4.0
Ext.grid.CheckColumn = Ext.ux.grid.CheckColumn;

// register Column xtype
Ext.grid.Column.types.checkcolumn = Ext.ux.grid.CheckColumn;

?

a.js

Ext.onReady(function() {	
	
    store=new Ext.data.JsonStore({
        url:'data.php',
        data:[],
        fields:[
            {name:'id'},
            {name:'mobile'},
            {name:'original_price'},
            {name:'current_price'},
            {name:'order_id'},
            {name:'time'},
            {name:'is_pay',type: 'bool'},
            {name:'is_recharge',type: 'bool'}
        ]
    });
    store.load();
    new Ext.grid.EditorGridPanel({
        store:store,
        mode:'remote',
        title:'充值列表',
        applyTo:'grid',
        height:500,
        frame:true,	
        
        cm:new Ext.grid.ColumnModel([
            {header:"ID",fixed:true,dataIndex:'id',sortable:true},
            {header:"手机",fixed:true,dataIndex:'mobile',sortable:true},
            {header:"原价",fixed:true,dataIndex:'original_price',sortable:true},
            {header:"现价",fixed:true,dataIndex:'current_price',sortable:true},
            {header:"订单",fixed:true,dataIndex:'order_id',sortable:true},
            {header:"时间",fixed:true,dataIndex:'time',sortable:true},            
            {header:"是否付款",xtype: 'checkcolumn',fixed:true,dataIndex:'is_pay',sortable:true,listeners:{afteredit:updateColumnValue}},            
            {header:"是否充值",xtype: 'checkcolumn',fixed:true,dataIndex:'is_recharge',sortable:true,listeners:{afteredit:updateColumnValue}
            }
           
        ])             
    });
    


    function updateColumnValue(e) {
    	
		  Ext.Ajax.request({   
		  	url:'http://www.hongyun2000.cn/index.php',
		  	method:'POST',
		  	params:e,
		  	success:function(result,request)
		  	{
		  		
		  	},
		  	failure:function(result,request)
		  	{
		  		Ext.MessageBox.alert('提示','请联系管理员');
		  	}
		  });
	}
   

});

?install.sql

--
-- 数据库: `www.hongyun2000.cn`
--

-- --------------------
--
-- 表的结构 `recharge`
--

DROP TABLE IF EXISTS `recharge`;
CREATE TABLE IF NOT EXISTS `recharge` (
  `id` mediumint(9) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `mobile` varchar(15) NOT NULL COMMENT '手机',
  `original_price` float NOT NULL COMMENT '原价',
  `current_price` float NOT NULL COMMENT '现价',
  `order_id` varchar(25) NOT NULL COMMENT '订单id',
  `time` datetime NOT NULL COMMENT '时间',
  `is_pay` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否付款',
  `is_recharge` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否充值',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
--
-- 导出表中的数据 `recharge`
--

INSERT INTO `recharge` (`id`, `mobile`, `original_price`, `current_price`, `order_id`, `time`, `is_pay`, `is_recharge`) VALUES
(1, '13525689561', 100, 95, 'HY123132456', '2015-05-10 00:00:00', 1, 0),
(2, '13356895689', 50, 46, 'HY123132457', '2011-01-18 15:41:47', 0, 0);

?

  相关解决方案