-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathCell.js
72 lines (63 loc) · 1.93 KB
/
Cell.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
define([
"dojo/_base/declare"
], function(declare){
return declare(/*===== "gridx.core.Cell", =====*/[], {
// summary:
// Represents a cell of a grid
// description:
// An instance of this class represents a grid cell.
// This class should not be directly instantiated by users. It should be returned by grid APIs.
/*=====
// row: [readonly] gridx.core.Row
// Reference to the row of this cell
row: null,
// column [readonly] gridx.core.Column
// Reference to the column of this cell
column: null,
// grid: [readonly] gridx.Grid
// Reference to the grid
grid: null,
// model: [readonly] grid.core.model.Model
// Reference to this grid model
model: null,
=====*/
constructor: function(grid, row, column){
var t=this;
t.grid = grid;
t.model = grid.model;
t.row = row;
t.column = column;
},
data: function(){
// summary:
// Get the grid data of this cell.
// description:
// Grid data means the result of the formatter functions (if exist).
// It can be different from store data (a.k.a. raw data).
// returns:
// The grid data in this cell
return this.model.byId(this.row.id).data[this.column.id]; //String|Number
},
rawData: function(){
// summary:
// Get the store data of this cell.
// description:
// If the column of this cell has a store field, then this method can return the store data of this cell.
// returns:
// The store data of this cell
var t = this, f = t.column.field();
return f && t.model.byId(t.row.id).rawData[f]; //anything
},
setRawData: function(rawData){
// summary:
// Set new raw data to this cell.
// rawData:
// Anything that store can recognize as data
// returns:
// If using server side store, a Deferred object is returned to indicate when the operation is finished.
var obj = {};
obj[this.column.field()] = rawData;
return this.row.setRawData(obj); //dojo.Deferred
}
});
});