Ext.define("Ext.ux.grid.filter.Array", {
	extend: "Ext.ux.grid.filter.Base",
	alias: "widget.filterarray",

	config: {
		where: "usrusrtkn in ( select  NAVERLRL00.ERLENTTKN " +
				"from navrolet00 , naverlrl00 " +
				"WHERE NAVERLRL00.ERLROLTKN = navrolet00.ROLROLTKN and NAVERLRL00.ERLENT = " +
				"'NAVUSRET00' and navrolet00.ROLROLTKN in ({[values]}) " +
				")"
	},

	initComponent: function() {

		var i_self = this;
		i_self.callParent(arguments);
	},

	createMenu: function() {

		var i_self = this;
		i_self.callParent(arguments);

		var config = {
			dataIndex: i_self.dataIndex,
			dataType: "array",
			overRuleable: i_self.overRuleable != null ? i_self.overRuleable : true,
			applyFn: i_self.applyFn || Ext.emptyFn,
			dmd: i_self.dmd,
			useRaw: i_self.useRaw != null ? i_self.useRaw : false,
			removeFn: i_self.removeFn || Ext.emptyFn
		};

		var i_panel = Ext.ux.grid.filter.util.create(config);

		i_self.config = config;
		i_self.menu.add(i_panel);
	},

	getFilterValue: function() {

		var i_self = this;
		var o_config = i_self.getConfig();
		var a_checkbox = o_config.checkboxes;
		var a_field = o_config.fields;
		var b_not = i_self.getNot();
		var a_value = "";
		var s_where = "";
		var s_criteria = "";
		var s_type = "";
		var n_index = 0;

		Ext.Array.each(a_checkbox, function(i_checkbox) {

			var i_field = a_field[n_index];

			if (i_checkbox.checked) {
				a_value = i_field.getValue();
				s_criteria = i_checkbox.criteria;
				s_type = i_checkbox.type;
			}
			n_index++;
		});

		if (a_value) {

			s_where = i_self.getWhereTemplete(a_value.join(","));
		}

		return s_where;
	},

	getWhereTemplete: function(value) {

		var i_self = this;

		var i_tpl = Ext.create('Ext.XTemplate',
			'<tpl>',
				i_self.getWhere(),
			'</tpl>'
		);
		i_tpl.compile();
		return i_tpl.apply(value);
	}
});
