UNPKG

1.11 kBJavaScriptView Raw
1/**
2 * Module : kero dataTable util
3 * Author : liuyk(liuyk@yonyou.com)
4 * Date : 2016-08-08 09:59:01
5 */
6import {
7 isArray
8} from 'tinper-sparrow/src/util';
9
10// 判断DataTable对象是否发生了改变
11const isChanged = function() {
12 var rows = this.getAllRows()
13 for (var i = 0; i < rows.length; i++) {
14 if (rows[i].status != Row.STATUS.NORMAL)
15 return true
16 }
17 return false
18}
19
20// 将Row对象转为索引数组或者将Row对象数组转为索引数组
21const _formatToIndicesArray = function(dataTableObj, indices) {
22 if (typeof indices == 'string' || typeof indices == 'number') {
23 indices = [indices]
24 } else if (indices instanceof Row) {
25 indices = [dataTableObj.getIndexByRowId(indices.rowId)]
26 } else if (isArray(indices) && indices.length > 0 && indices[0] instanceof Row) {
27 for (var i = 0; i < indices.length; i++) {
28 indices[i] = dataTableObj.getIndexByRowId(indices[i].rowId)
29 }
30 }
31 return indices;
32};
33
34export const utilFunObj = {
35 isChanged: isChanged,
36 _formatToIndicesArray: _formatToIndicesArray
37
38}