MCPcopy
hub / github.com/layui/layui / eachChildCols

Function eachChildCols

src/modules/table.js:3894–3926  ·  view source on GitHub ↗
(index, cols, i1, item2)

Source from the content-addressed store, hash-verified

3892 thisTable.config = {}; //记录所有实例配置项
3893
3894 var eachChildCols = function (index, cols, i1, item2) {
3895 //如果是组合列,则捕获对应的子列
3896 if (item2.colGroup) {
3897 var childIndex = 0;
3898 index++;
3899 item2.CHILD_COLS = [];
3900 // 找到它的子列所在cols的下标
3901 var i2 = i1 + (parseInt(item2.rowspan) || 1);
3902 layui.each(cols[i2], function (i22, item22) {
3903 if (item22.parentKey) {
3904 // 如果字段信息中包含了parentKey和key信息
3905 if (item22.parentKey === item2.key) {
3906 item22.PARENT_COL_INDEX = index;
3907 item2.CHILD_COLS.push(item22);
3908 eachChildCols(index, cols, i2, item22);
3909 }
3910 } else {
3911 // 没有key信息以colspan数量所谓判断标准
3912 //如果子列已经被标注为{PARENT_COL_INDEX},或者子列累计 colspan 数等于父列定义的 colspan,则跳出当前子列循环
3913 if (
3914 item22.PARENT_COL_INDEX ||
3915 (childIndex >= 1 && childIndex == (item2.colspan || 1))
3916 )
3917 return;
3918 item22.PARENT_COL_INDEX = index;
3919 item2.CHILD_COLS.push(item22);
3920 childIndex =
3921 childIndex + parseInt(item22.colspan > 1 ? item22.colspan : 1);
3922 eachChildCols(index, cols, i2, item22);
3923 }
3924 });
3925 }
3926 };
3927
3928 // 遍历表头
3929 table.eachCols = function (id, callback, cols) {

Callers 1

table.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected