1 | ## Objects
|
2 |
|
3 | <dl>
|
4 | <dt><a href="#Row">Row</a> : <code>object</code></dt>
|
5 | <dd><p>前端数据模型行对象</p>
|
6 | </dd>
|
7 | </dl>
|
8 |
|
9 | ## Functions
|
10 |
|
11 | <dl>
|
12 | <dt><a href="#resetValue">resetValue()</a></dt>
|
13 | <dd><p>重置数据至nrm状态时的数据</p>
|
14 | </dd>
|
15 | </dl>
|
16 |
|
17 | <a name="Row"></a>
|
18 |
|
19 | ## Row : <code>object</code>
|
20 | 前端数据模型行对象
|
21 |
|
22 |
|
23 | * [Row](#Row) : <code>object</code>
|
24 | * _instance_
|
25 | * [.rowId](#Row+rowId) : <code>string</code>
|
26 | * [.status](#Row+status) : <code>string</code>
|
27 | * [.parent](#Row+parent) : <code>u.DataTable</code>
|
28 | * _static_
|
29 | * [.setValue(fieldName, value, [ctx])](#Row.setValue)
|
30 | * [.setData(data, [subscribe], [options])](#Row.setData)
|
31 | * [.setStatus(status)](#Row.setStatus)
|
32 | * [.getValue(fieldName)](#Row.getValue) ⇒ <code>string</code>
|
33 | * [.getData()](#Row.getData) ⇒ <code>object</code>
|
34 | * [.getSimpleData([options])](#Row.getSimpleData) ⇒ <code>object</code>
|
35 | * [.setSimpleData(data, [status])](#Row.setSimpleData)
|
36 | * [.toggleSelect([type])](#Row.toggleSelect)
|
37 | * [.getMeta(fieldName, key, [fetchParent])](#Row.getMeta) ⇒ <code>string</code>
|
38 | * [.setMeta(fieldName, key, value)](#Row.setMeta)
|
39 | * [.ref(fieldName)](#Row.ref)
|
40 | * [.refMeta(fieldName, key)](#Row.refMeta)
|
41 | * [.refCombo(fieldName, datasource)](#Row.refCombo)
|
42 | * [.refDate(fieldName, format)](#Row.refDate)
|
43 |
|
44 | <a name="Row+rowId"></a>
|
45 |
|
46 | ### row.rowId : <code>string</code>
|
47 | 当前行的唯一标识
|
48 |
|
49 | <a name="Row+status"></a>
|
50 |
|
51 | ### row.status : <code>string</code>
|
52 | 当前行的状态
|
53 | Row.STATUS.NORMAL('nrm') :前后端都存在并且保持一致
|
54 | Row.STATUS.UPDATE('upd') :前后端都存在并且前端进行了修改
|
55 | Row.STATUS.NEW('new') :后端不存在,前端存在的数据
|
56 | Row.STATUS.DELETE('del') :后端请求返回的状态,前端判断为此状态则将数据删除
|
57 | Row.STATUS.FALSE_DELETE('fdel') :后端存在,前端不存在的数据
|
58 |
|
59 | **Default**: <code>"Row.STATUS.NEW"</code>
|
60 | <a name="Row+parent"></a>
|
61 |
|
62 | ### row.parent : <code>u.DataTable</code>
|
63 | 当前行对应的DataTable对象
|
64 |
|
65 | <a name="Row.setValue"></a>
|
66 |
|
67 | ### Row.setValue(fieldName, value, [ctx])
|
68 | 设置对应字段的值
|
69 |
|
70 |
|
71 | | 参数 | Type | Description |
|
72 | | --- | --- | --- |
|
73 | | fieldName | <code>string</code> | 需要设置的字段 |
|
74 | | value | <code>string</code> | 需要设置的值 |
|
75 | | [ctx] | <code>\*</code> | 自定义属性,在valuechange监听传入对象中可通过ctx获取此处设置 |
|
76 |
|
77 | **Example**
|
78 | ```js
|
79 | row.setValue('filed1','value1') // 设置字段值
|
80 | row.setValue('filed1','value1','ctx') //设置字段值,同时传入自定义数据
|
81 | ```
|
82 | <a name="Row.setData"></a>
|
83 |
|
84 | ### Row.setData(data, [subscribe], [options])
|
85 | 设置row的数据信息
|
86 |
|
87 |
|
88 | | 参数 | Type | Description |
|
89 | | --- | --- | --- |
|
90 | | data | <code>object</code> | 需要设置的配置信息 |
|
91 | | [subscribe] | <code>boolean</code> | 是否触发监听,true表示触发监听 |
|
92 | | [options] | <code>object</code> | 设置数据信息是的配置参数 |
|
93 | | [options.fieldFlag] | <code>boolean</code> | 未设置的meta是否进行存储,如果为true则未设置的meta也进行存储 |
|
94 |
|
95 | **Example**
|
96 | ```js
|
97 | var data = {
|
98 | filed1:'value1',
|
99 | field2:'value2'
|
100 | }
|
101 | row.setData(data)
|
102 | row.setData(data,false)
|
103 | row.setData(data),false,{fieldFlag:true})
|
104 | ```
|
105 | <a name="Row.setStatus"></a>
|
106 |
|
107 | ### Row.setStatus(status)
|
108 | 设置row的status属性
|
109 |
|
110 |
|
111 | | 参数 | Type | Description |
|
112 | | --- | --- | --- |
|
113 | | status | <code>string</code> | 需要设置的status |
|
114 |
|
115 | **Example**
|
116 | ```js
|
117 | row.setStatus(Row.STATUS.NORMAL)
|
118 | ```
|
119 | <a name="Row.getValue"></a>
|
120 |
|
121 | ### Row.getValue(fieldName) ⇒ <code>string</code>
|
122 | 获取row中某一字段的值
|
123 |
|
124 | **Returns**: <code>string</code> - 字段值
|
125 |
|
126 | | 参数 | Type | Description |
|
127 | | --- | --- | --- |
|
128 | | fieldName | <code>string</code> | 字段名 |
|
129 |
|
130 | **Example**
|
131 | ```js
|
132 | row.getValue('field1')
|
133 | ```
|
134 | <a name="Row.getData"></a>
|
135 |
|
136 | ### Row.getData() ⇒ <code>object</code>
|
137 | 获取数据信息
|
138 |
|
139 | **Returns**: <code>object</code> - 格式如下:{'id': this.rowId, 'status': this.status, data: data}
|
140 | **Example**
|
141 | ```js
|
142 | row.getData()
|
143 | ```
|
144 | <a name="Row.getSimpleData"></a>
|
145 |
|
146 | ### Row.getSimpleData([options]) ⇒ <code>object</code>
|
147 | 获取数据信息
|
148 |
|
149 | **Returns**: <code>object</code> - 数据信息
|
150 |
|
151 | | 参数 | Type | Description |
|
152 | | --- | --- | --- |
|
153 | | [options] | <code>object</code> | 获取数据信息时的配置参数 |
|
154 | | [options.fields] | <code>array</code> | 获取数据信息时是否制定字段值 |
|
155 |
|
156 | **Example**
|
157 | ```js
|
158 | row.getSimpleData()
|
159 | row.getSimpleData({fields:['field1','field2']})
|
160 | ```
|
161 | <a name="Row.setSimpleData"></a>
|
162 |
|
163 | ### Row.setSimpleData(data, [status])
|
164 | 设置数据, 只设置字段值
|
165 |
|
166 |
|
167 | | 参数 | Type | Default | Description |
|
168 | | --- | --- | --- | --- |
|
169 | | data | <code>object</code> | | 数据信息 |
|
170 | | [status] | <code>boject</code> | <code>nrm</code> | 数据行状态 |
|
171 |
|
172 | **Example**
|
173 | ```js
|
174 | var data = {
|
175 | filed1:'value1',
|
176 | field2:'value2'
|
177 | }
|
178 | datatable.setSimpleData(data)
|
179 | datatable.setSimpleData(data,'upd')
|
180 | ```
|
181 | <a name="Row.toggleSelect"></a>
|
182 |
|
183 | ### Row.toggleSelect([type])
|
184 | 切换数据行的选中状态
|
185 |
|
186 |
|
187 | | 参数 | Type | Description |
|
188 | | --- | --- | --- |
|
189 | | [type] | <code>boolean</code> | 执行选中操作时,如果为single则取消其他行的选中状态,否则只修改当前行的选中状态 |
|
190 |
|
191 | **Example**
|
192 | ```js
|
193 | row.toggleSelect()
|
194 | row.toggleSelect('single')
|
195 | row.toggleSelect('multi')
|
196 | ```
|
197 | <a name="Row.getMeta"></a>
|
198 |
|
199 | ### Row.getMeta(fieldName, key, [fetchParent]) ⇒ <code>string</code>
|
200 | 获取字段的属性
|
201 |
|
202 | **Returns**: <code>string</code> - 属性值
|
203 |
|
204 | | 参数 | Type | Default | Description |
|
205 | | --- | --- | --- | --- |
|
206 | | fieldName | <code>string</code> | | 字段名 |
|
207 | | key | <code>string</code> | | 属性名 |
|
208 | | [fetchParent] | <code>boolean</code> | <code>false</code> | 未定义时是否去DataTable对象查找,为true则未定义时去DataTable对象查找 |
|
209 |
|
210 | **Example**
|
211 | ```js
|
212 | row.getMeta('field1','type')
|
213 | row.getMeta('field1','type',true)
|
214 | ```
|
215 | <a name="Row.setMeta"></a>
|
216 |
|
217 | ### Row.setMeta(fieldName, key, value)
|
218 | 设置meta信息
|
219 |
|
220 |
|
221 | | 参数 | Type | Description |
|
222 | | --- | --- | --- |
|
223 | | fieldName | <code>string</code> | 需要设置meta信息的字段名 |
|
224 | | key | <code>string</code> | meta信息的key |
|
225 | | value | <code>string</code> | meta信息的值 |
|
226 |
|
227 | **Example**
|
228 | ```js
|
229 | row.setMeta('filed1','type','string')
|
230 | ```
|
231 | <a name="Row.ref"></a>
|
232 |
|
233 | ### Row.ref(fieldName)
|
234 | 为某个字段绑定监听,当字段发生改变时触发对应方法
|
235 |
|
236 |
|
237 | | 参数 | Type | Description |
|
238 | | --- | --- | --- |
|
239 | | fieldName | <code>string</code> | 绑定的字段名 |
|
240 |
|
241 | **Example**
|
242 | ```js
|
243 | row.ref('field1').subscribe(function(){})
|
244 | ```
|
245 | <a name="Row.refMeta"></a>
|
246 |
|
247 | ### Row.refMeta(fieldName, key)
|
248 | 绑定字段属性,当字段属性发生改变时触发对应方法
|
249 |
|
250 |
|
251 | | 参数 | Type | Description |
|
252 | | --- | --- | --- |
|
253 | | fieldName | <code>string</code> | 绑定的字段名 |
|
254 | | key | <code>string</code> | 绑定的属性key |
|
255 |
|
256 | **Example**
|
257 | ```js
|
258 | row.refMeta('field1','type').subscribe(function(){})
|
259 | ```
|
260 | <a name="Row.refCombo"></a>
|
261 |
|
262 | ### Row.refCombo(fieldName, datasource)
|
263 | 为某个字段绑定监听,当字段发生改变时触发对应方法,针对下拉字段根据key转化为对应的value
|
264 |
|
265 |
|
266 | | 参数 | Type | Description |
|
267 | | --- | --- | --- |
|
268 | | fieldName | <code>string</code> | 绑定的字段名 |
|
269 | | datasource | <code>string</code> | 下拉数据源变量名 |
|
270 |
|
271 | **Example**
|
272 | ```js
|
273 | row.refCombo('field1','source1').subscribe(function(){})
|
274 | ```
|
275 | <a name="Row.refDate"></a>
|
276 |
|
277 | ### Row.refDate(fieldName, format)
|
278 | 为某个字段绑定监听,当字段发生改变时触发对应方法,针对日期字段进行格式化
|
279 |
|
280 |
|
281 | | 参数 | Type | Description |
|
282 | | --- | --- | --- |
|
283 | | fieldName | <code>string</code> | 绑定的字段名 |
|
284 | | format | <code>string</code> | 格式化规则 |
|
285 |
|
286 | **Example**
|
287 | ```js
|
288 | row.refDate('field1','YYYY-MM-DD').subscribe(function(){})
|
289 | ```
|
290 | <a name="resetValue"></a>
|
291 |
|
292 | ## resetValue()
|
293 | 重置数据至nrm状态时的数据
|
294 |
|
295 | **Example**
|
296 | ```js
|
297 | row.resetValue()
|
298 | ```
|