MCPcopy Create free account
hub / github.com/layui/layui / initChildCols

Function initChildCols

src/modules/table.js:734–773  ·  view source on GitHub ↗
(i1, item1, i2, item2)

Source from the content-addressed store, hash-verified

732
733 // 封装对 col 的配置处理
734 var initChildCols = function (i1, item1, i2, item2) {
735 //如果列参数为空,则移除
736 if (!item2) {
737 item1.splice(i2, 1);
738 return;
739 }
740
741 item2.key = [options.index, i1, i2].join('-');
742 item2.colspan = item2.colspan || 0;
743 item2.rowspan = item2.rowspan || 0;
744
745 //根据列类型,定制化参数
746 that.initOpts(item2);
747
748 //设置列的父列索引
749 //如果是组合列,则捕获对应的子列
750 var indexChild = i1 + (parseInt(item2.rowspan) || 1);
751 if (indexChild < options.cols.length) {
752 // 只要不是最后一层都会有子列
753 item2.colGroup = true;
754 var childIndex = 0;
755 layui.each(options.cols[indexChild], function (i22, item22) {
756 //如果子列已经被标注为{HAS_PARENT},或者子列累计 colspan 数等于父列定义的 colspan,则跳出当前子列循环
757 if (
758 item22.HAS_PARENT ||
759 (childIndex >= 1 && childIndex == (item2.colspan || 1))
760 )
761 return;
762
763 item22.HAS_PARENT = true;
764 item22.parentKey = [options.index, i1, i2].join('-'); // i1 + '-' + i2;
765 childIndex =
766 childIndex + parseInt(item22.colspan > 1 ? item22.colspan : 1);
767 initChildCols(indexChild, options.cols[indexChild], i22, item22);
768 });
769 } else {
770 item2.colGroup = false;
771 }
772 item2.hide = (item2.hide && !item2.colGroup) || false; // 初始化中中间节点的hide信息不做处理,否则会出错,如果需要必须将其子节点也都同步成hide
773 };
774
775 // 初始化列参数
776 layui.each(options.cols, function (i1, item1) {

Callers 1

table.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected