Ext.namespace('Ext.ux.grid');
Ext.ux.grid.RowActions=function(config)
{
	Ext.apply(this,config);
	Ext.ux.grid.RowActions.superclass.constructor.call(this);
}
Ext.extend
(
	Ext.ux.grid.RowActions,
	Ext.util.Observable,
	{
		grid:			null,
		view:			null,
		header:			'Actions',
		width:			100,
		sortable:		false,
		fixed:			true,
		menuDisabled:	true,
		dataIndex:		'',
		id:				'rowActions',
		actions:		[],
//		skipRender:		true,
		init:			function(grid)
		{
			this.grid		=grid;
			this.view		=grid.getView();
		},
		renderer: function(value,metaData,record,rowIndex,ColIndex,store)
		{
			if (!this.actions.length)return '';
			var ret		=[],
				ids		={},
				thisID	=null;
			for (var i=0,j=this.actions.length; i<j; i++)
			{
				if (this.actions[i].ignore)continue;
				thisID=Ext.id();
				ids[thisID]=
				{
					fn:		this.actions[i].handler || Ext.emptyFn,
					tip:	this.actions[i].tooltip
				};
				ret.push('<div id="'+thisID+'" class="rowAction-item '+this.actions[i].iconCls+'">&nbsp;</div>');
			}
			(function(ids)
			{
				for (var id in ids)
				{
					if (Ext.get(id))
					{
						Ext.get(id).on
						(
							'click',
							function(record,store,id)
							{
								ids[id].fn(record,store);
							}.bind(this,record,store,id)
						);
						new Ext.ToolTip
						(
							{
								target:			id,
								anchor:			'top',
								anchorOffset:	-10,
								showDelay:		0,
								hideDelay:		0,
								html:			ids[id].tip
							}
						);
					}
				}
			}.bind(this,ids)).defer(1000);
			return ret.join('');
		}
	}
);
