UNPKG

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