kero
Version:
<img src="http://tinper.org/assets/images/kero.png" width="120" style="max-width:100%;"/>
39 lines (34 loc) • 1.11 kB
JavaScript
/**
* Module : kero dataTable util
* Author : liuyk(liuyk@yonyou.com)
* Date : 2016-08-08 09:59:01
*/
import {
isArray
} from 'tinper-sparrow/src/util';
// 判断DataTable对象是否发生了改变
const isChanged = function() {
var rows = this.getAllRows()
for (var i = 0; i < rows.length; i++) {
if (rows[i].status != Row.STATUS.NORMAL)
return true
}
return false
}
// 将Row对象转为索引数组或者将Row对象数组转为索引数组
const _formatToIndicesArray = function(dataTableObj, indices) {
if (typeof indices == 'string' || typeof indices == 'number') {
indices = [indices]
} else if (indices instanceof Row) {
indices = [dataTableObj.getIndexByRowId(indices.rowId)]
} else if (isArray(indices) && indices.length > 0 && indices[0] instanceof Row) {
for (var i = 0; i < indices.length; i++) {
indices[i] = dataTableObj.getIndexByRowId(indices[i].rowId)
}
}
return indices;
};
export const utilFunObj = {
isChanged: isChanged,
_formatToIndicesArray: _formatToIndicesArray
}