layui实现动态表头的思路求解

问题遇到的现象和发生背景

参数只有年份,去查表(mysql5.7),看看有几月的数据,如果有一月,页面表头就显示一月,如果有123月就显示123月的,导出excel的表头同样是这个思路。

我的想法是,先查询出都不为空的列,然后动态拼接表头,问题是isNull,只能判断某一列,没办法判断多列,有什么办法或者别的思路解决吗?

img

img


{
                    field: 'Count1',
                    title: yearMonth + '01月人数',
                    width: "160",
                    align: 'center', templet: function (d) {
                        if ((d.Count1 == null || d.Count1 == "") && index == 0) {
                            var field = d.LAY_COL.field;
                            month = field.substring(9, field.length);
                            index++;
                        }
                        return d.Count1;
                    }
                }

https://blog.csdn.net/kids_fan/article/details/122643022