| 175 | | function change(val) { |
|---|
| 176 | | if (val > 0) { |
|---|
| 177 | | val = '<span style="color:green;">' + val + '</span>'; |
|---|
| 178 | | } |
|---|
| 179 | | else if(val < 0) { |
|---|
| 180 | | val = '<span style="color:red;">' + val + '</span>'; |
|---|
| 181 | | } |
|---|
| 182 | | return val; |
|---|
| 183 | | } |
|---|
| 184 | | |
|---|
| 185 | | function pctChange(val) { |
|---|
| 186 | | if (val > 0) { |
|---|
| 187 | | val = '<span style="color:green;">' + val + '%</span>'; |
|---|
| 188 | | } |
|---|
| 189 | | else if(val < 0) { |
|---|
| 190 | | val = '<span style="color:red;">' + val + '%</span>'; |
|---|
| 191 | | } |
|---|
| 192 | | return val; |
|---|
| 193 | | } |
|---|
| 194 | | |
|---|
| 195 | | function workRenderer(value, element, record){ |
|---|
| 196 | | alert(record.id); |
|---|
| 197 | | return value ? String.format('{0} {1}', record.data['work'], record.data['workUnits']) : ''; |
|---|
| 198 | | } |
|---|
| 199 | | |
|---|
| | 206 | |
|---|
| | 207 | TreeGrid.prototype.getRecordById = function getRecordById(id){ |
|---|
| | 208 | var result = null; |
|---|
| | 209 | if(null != id){ |
|---|
| | 210 | var store = this.getStore(); |
|---|
| | 211 | result = store.getById(id); |
|---|
| | 212 | } |
|---|
| | 213 | return result; |
|---|
| | 214 | } |
|---|
| | 215 | |
|---|
| | 216 | TreeGrid.prototype.getSelectedRowIdFromGrid = function getSelectedRowIdFromGrid(){ |
|---|
| | 217 | // Selected records are driven by highligthed grid rows |
|---|
| | 218 | var selectionModel = this.getSelectionModel(); |
|---|
| | 219 | var rowCount = selectionModel.getCount(); |
|---|
| | 220 | |
|---|
| | 221 | // First, test at least one row was selected |
|---|
| | 222 | if(rowCount == 0){ |
|---|
| | 223 | return -1; |
|---|
| | 224 | } |
|---|
| | 225 | |
|---|
| | 226 | // Now, test only one row was selected |
|---|
| | 227 | if(rowCount > 1){ |
|---|
| | 228 | return -2; |
|---|
| | 229 | } |
|---|
| | 230 | return selectionModel.getSelected().id; |
|---|
| | 231 | }; |
|---|
| | 232 | |
|---|
| | 233 | TreeGrid.prototype.getSelectedNonLastRowIdFromGrid = function getSelectedNonLastRowIdFromGrid(){ |
|---|
| | 234 | var selectionModel = this.getSelectionModel(); |
|---|
| | 235 | var rowCount = selectionModel.getCount(); |
|---|
| | 236 | |
|---|
| | 237 | // First, test at least one row was selected |
|---|
| | 238 | if(rowCount == 0){ |
|---|
| | 239 | return -1; |
|---|
| | 240 | } |
|---|
| | 241 | |
|---|
| | 242 | // Now, test only one row was selected |
|---|
| | 243 | if(rowCount > 1){ |
|---|
| | 244 | return -2; |
|---|
| | 245 | } |
|---|
| | 246 | |
|---|
| | 247 | // Test it's not the last record. |
|---|
| | 248 | if(selectionModel.hasNext()){ |
|---|
| | 249 | return selectionModel.getSelected().id; |
|---|
| | 250 | } else{ |
|---|
| | 251 | return -3; |
|---|
| | 252 | } |
|---|
| | 253 | }; |
|---|
| | 254 | |
|---|
| | 255 | TreeGrid.prototype.getSelectedNonFirstRowIdFromGrid = function getSelectedNonFirstRowIdFromGrid(){ |
|---|
| | 256 | var selectionModel = this.getSelectionModel(); |
|---|
| | 257 | var rowCount = selectionModel.getCount(); |
|---|
| | 258 | |
|---|
| | 259 | // First, test at least one row was selected |
|---|
| | 260 | if(rowCount == 0){ |
|---|
| | 261 | return -1; |
|---|
| | 262 | } |
|---|
| | 263 | |
|---|
| | 264 | // Now, test only one row was selected |
|---|
| | 265 | if(rowCount > 1){ |
|---|
| | 266 | return -2; |
|---|
| | 267 | } |
|---|
| | 268 | |
|---|
| | 269 | // Test it's not the first record. |
|---|
| | 270 | if(selectionModel.hasPrevious()){ |
|---|
| | 271 | return selectionModel.getSelected().id; |
|---|
| | 272 | } else{ |
|---|
| | 273 | return -3; |
|---|
| | 274 | } |
|---|
| | 275 | }; |
|---|
| | 276 | |
|---|
| | 277 | TreeGrid.prototype.getSelectedRowIdsFromGrid = function getSelectedRowIdFromGrid(){ |
|---|
| | 278 | // Selected records are driven by highligthed grid rows |
|---|
| | 279 | var selectionModel = this.getSelectionModel(); |
|---|
| | 280 | var rowCount = selectionModel.getCount(); |
|---|
| | 281 | |
|---|
| | 282 | // Test at least one row was selected |
|---|
| | 283 | if(rowCount == 0){ |
|---|
| | 284 | return -1; |
|---|
| | 285 | } |
|---|
| | 286 | |
|---|
| | 287 | var selectedRows = selectionModel.getSelections(); |
|---|
| | 288 | var ids = new Array(); |
|---|
| | 289 | for(var i = 0; i < selectedRows.length; i++){ |
|---|
| | 290 | ids[ids.length] = selectedRows[i].id; |
|---|
| | 291 | } |
|---|
| | 292 | |
|---|
| | 293 | return ids; |
|---|
| | 294 | }; |
|---|
| | 295 | |
|---|
| | 296 | TreeGrid.prototype.getSelectedRowIdsOnlyFromGrid = function getSelectedRowIdOnlyFromGrid(){ |
|---|
| | 297 | var selectionModel = this.getSelectionModel(); |
|---|
| | 298 | var rowCount = selectionModel.getCount(); |
|---|
| | 299 | |
|---|
| | 300 | // Test at least two rows were selected |
|---|
| | 301 | if(rowCount <= 1){ |
|---|
| | 302 | return -1; |
|---|
| | 303 | } |
|---|
| | 304 | |
|---|
| | 305 | var selectedRows = selectionModel.getSelections(); |
|---|
| | 306 | var ids = new Array(); |
|---|
| | 307 | for(var i = 0; i < selectedRows.length; i++){ |
|---|
| | 308 | ids[ids.length] = selectedRows[i].id; |
|---|
| | 309 | } |
|---|
| | 310 | |
|---|
| | 311 | return ids; |
|---|
| | 312 | }; |
|---|