﻿Ext.ns("eKonx.UI");

Ext.apply(eKonx.UI,
{
	GetCellSelectionModel: function()
	{
		return new Ext.grid.CellSelectionModel(
		{
			listeners:
			{
				beforecellselect: function(sm, rowIndex, colIndex)
				{
					var colModel = this.grid.getColumnModel();
					var col = colModel.getColumnById(colModel.getColumnId(colIndex));
					if ((col != null) && (col.isAction))
					{
						if (col.click)
							col.click.call(this, col, rowIndex, this.grid.getStore().getAt(rowIndex).data);
						return false;
					}
					return true;
				}
			}
		});
	}
});

eKonx.UI.GetGridToolbar = function(tStore, addHandler, saveHandler)
{
	var bar =
	{
		//pageSize: 25,
		xtype: 'paging',
		store: tStore,
		displayInfo: true,
		//displayMsg: 'Displaying topics {0} - {1} of {2}',
		//emptyMsg: "No topics to display",
		remoteSort: true,
		items:
		[
			'-',
			{
				xtype: 'button',
				text: eKonx.Res.Common.AddButton,
				iconCls: 'silk-add',
				width: 50,
				handler: addHandler
			},
			'-',
			{
				xtype: 'button',
				text: eKonx.Res.Common.SaveButton,
				iconCls: 'icon-save',
				width: 50,
				handler: saveHandler
			}
		]
	};
	return bar;
}


