1 /**
  2  * @author Gillis Haasnoot <gillis.haasnoot@gmail.com>
  3  * @package Banana.Controls
  4  * @summary DataGridColumn 
  5  */
  6 
  7 goog.provide('Banana.Controls.DataControls.ListControls.DataGrid.ColumnControls.DataGridColumn');
  8 
  9 /** @namespace Banana.Controls.DataGridColumn */
 10 namespace('Banana.Controls').DataGridColumn = Banana.Control.extend(
 11 /** @lends Banana.Controls.DataGridColumn.prototype */
 12 {
 13 	/**
 14 	 * Creates datagrid column for usage in table list renders
 15 	 * @constructs
 16 	 * @extends Banana.Control
 17 	 */
 18 	init : function()
 19 	{
 20 		this._super();
 21 		
 22 		this.attributes = {};
 23 	},
 24 	
 25 	/**
 26 	 * @ignore
 27 	 * @return {Banana.DataControl}
 28 	 */
 29 	getControl : function()
 30 	{
 31 		return new Banana.Controls.Label();
 32 	},
 33 	
 34 	/**
 35 	 * sets the current idex where the column is created in
 36 	 * @ignore
 37 	 * @param {int} index
 38 	 */
 39 	setCurrentIndexCreation : function(index)
 40 	{
 41 		this.currentIndexCreation = index;
 42 	}	
 43 
 44 });
 45 
 46 /**
 47  * Sets data on the column.
 48  * Automaticaly called by the list render.
 49  *
 50  * @param {mixed} data
 51  * @return {this}
 52  */
 53 Banana.Controls.DataGridColumn.prototype.setData = function(data)
 54 {
 55 	this.data = data;
 56 	return this;
 57 };
 58 
 59 /**
 60  * @return {mixed}
 61  */
 62 Banana.Controls.DataGridColumn.prototype.getData = function()
 63 {
 64 	return this.data;
 65 };
 66 
 67 /**
 68  * sets sortfield 
 69  * Note: for reference material only. we dont do realy anything with it.
 70  *
 71  * @param {String} field
 72  * @return {this}
 73  */
 74 Banana.Controls.DataGridColumn.prototype.setSortField = function(field)
 75 {
 76 	this.sortField = field;
 77 	return this;
 78 };
 79 
 80 /**
 81  * Sets the header text visible in grid on top of each column
 82  *
 83  * @param {String} text
 84  * @return {this}
 85  */
 86 Banana.Controls.DataGridColumn.prototype.setHeaderText = function(text)
 87 {
 88 	this.headerText = text;
 89 	return this;
 90 };
 91 
 92 /**
 93  * returns the header text visible in grid on top of each column
 94  *
 95  * @return {String}
 96  */
 97 Banana.Controls.DataGridColumn.prototype.getHeaderText = function()
 98 {
 99 	return this.headerText;
100 };
101 
102 /**
103  * use property of data object which should be applied to the column control
104  * If your data looks like {name:"foo",id:12} 
105  * you can use either setDataField("name") or setDataField("id")
106  *
107  * @param {String} fields
108  * @return {this}
109  */
110 Banana.Controls.DataGridColumn.prototype.setDataField = function(field)
111 {
112 	this.dataField = field;
113 	return this;
114 };
115 
116 /**
117  * @return {String}
118  */
119 Banana.Controls.DataGridColumn.prototype.getDataField = function()
120 {
121 	return this.dataField;
122 };
123 
124 /**
125  * Sets reference to list render
126  * @ignore
127  * @param {Banana.Controls.DataGridTableListRender} lr
128  */
129 Banana.Controls.DataGridColumn.prototype.setListRender = function(lr)
130 {
131 	this.listRender = lr;
132 	return this;
133 };
134 
135 /**
136  * gets reference to the underlying list render.
137  * @return {Banana.Controls.DataGridTableListRender}
138  */
139 Banana.Controls.DataGridColumn.prototype.getListRender = function()
140 {
141 	return this.listRender;
142 };
143 
144 /**
145  * Sets reference to wrapper row control arround each column
146  * @ignore
147  * @param {Banana.Controls.TableRow} r
148  * @return {this}
149  */
150 Banana.Controls.DataGridColumn.prototype.setOwnerRow = function(r)
151 {
152 	this.ownerRow = r;
153 	return this;
154 };
155 
156 /**
157  * @ignore
158  * @return {Banana.Controls.TableRow}
159  */
160 Banana.Controls.DataGridColumn.prototype.getOwnerRow = function()
161 {
162 	return this.ownerRow;
163 };
164 
165 /**
166  * Sets style applied in the header on top of each row
167  * @param {String} css
168  * @return {this}
169  */
170 Banana.Controls.DataGridColumn.prototype.setHeaderStyle = function(css)
171 {
172 	this.headerStyle = css;
173 	return this;
174 };
175 
176 /**
177  * @return {String}
178  */
179 Banana.Controls.DataGridColumn.prototype.getHeaderStyle = function(css)
180 {
181 	return this.headerStyle;
182 };
183 
184 /**
185  * Sets style in this column
186  * @param {String} css
187  * @return {this} 
188  */
189 Banana.Controls.DataGridColumn.prototype.setStyle = function(css)
190 {
191 	this.style = css;
192 	return this;
193 };
194 
195 /**
196  * @return {String}
197  */
198 Banana.Controls.DataGridColumn.prototype.getStyle = function(css)
199 {
200 	return this.style;
201 };
202 
203 /**
204  * @param {boolean} visible
205  */
206 Banana.Controls.DataGridColumn.prototype.setVisible = function(visible)
207 {
208 	this.visible = visible;
209 	return this;
210 };
211 
212 /**
213  * @return {boolean}
214  */
215 Banana.Controls.DataGridColumn.prototype.getVisible = function(v)
216 {
217 	return this.visible;
218 };
219 
220 /**
221  * Sets attribute
222  *  
223  * @param {String} attribute 
224  * @param {String} value
225  * @return {this}
226  */
227 Banana.Controls.DataGridColumn.prototype.setAttribute = function(attribute,value)
228 {
229 	this.attributes[attribute ] = value;
230 	return this;
231 };