查看: 611|回复: 5

创建列表时,行数据重复。

升级   0.72%

10

主题

11

回帖

72

积分

注册会员

Rank: 2

积分
72
发表于 2024-11-4 09:24:36 | 显示全部楼层 |阅读模式
datatable列表,在for循环里使用var line = this.form.get('dt1').[size=0.88em]addLine();创建列表行时会有重复的行。请问是为何呢?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

升级   100%

139

主题

1万

回帖

4万

积分

超级版主

Rank: 8Rank: 8

积分
41458
发表于 2024-11-4 10:27:07 | 显示全部楼层
var line = this.form.get("dt1").addLine();   在哪里调用的,截图看看
回复

使用道具 举报

升级   0.72%

10

主题

11

回帖

72

积分

注册会员

Rank: 2

积分
72
发表于 2024-11-4 10:46:00 | 显示全部楼层
本帖最后由 Nathan 于 2024-11-4 11:51 编辑

[AppleScript] 纯文本查看 复制代码
/**
                 * 在数据表格末尾添加条目。
                 * @param {Object} [data] 添加条目的数据。
                 * @return {MWF.xApplication.process.Xform.DatatablePC.Line} 添加的数据表格条目
                 * @example
                 * var line = this.form.get("dt1").addLine();
                 */
               
        var unitid = this.session.user.identityList[0].unit;     //    获取组织id

        var personList1 = this.org.listPersonWithUnit( unitid );     //根据组织id获取人员

        
                var namesList = [];
               
                 for (var i = 0; i < personList1.length; i++) {
               
                                 
                                var promise = this.org.listPersonAllAttribute( personList1, true);
                                 
                               promise.then(function(attributeObjectList){
                                         
        
                                   for (var j = 0; j < attributeObjectList.length; j++) {
                                           var nl = attributeObjectList[j].name;
                                           var attributeList = attributeObjectList[j].attributeList;
                                            console.log("nl-->"+JSON.stringify(nl));
                                                if(attributeList == "company"){
                                                        console.log("attributeList"+ JSON.stringify(attributeList));
                                                        //1 没有添加上是为何?
                                              namesList.push(personList1.name);
                                               
                                                }
                                                console.log("attributeList2"+ JSON.stringify(attributeList));
                                   }
                                 
                 })
                               //2 号问题!!!! 这里 添加重复的行序号    1 1  2  2 3  3  4  4  5  5
                                 var line = this.form.get("datatable").addLine();
        
         
        }
               
console.log("211111 - "+JSON.stringify(namesList));//输出为空

for (var i = 0; i < namesList.length; i++) {
//         var line = this.form.get("datatable").addLine();
在里想 把namesList选出的同部门 (企业或事业编)的企业的人找出来,并创建行数据
}
代码里 有俩问题,1 nameList存不上值 2.创建行有重复。请问您我要怎么改呢??
回复

使用道具 举报

升级   0.72%

10

主题

11

回帖

72

积分

注册会员

Rank: 2

积分
72
发表于 2024-11-4 11:43:27 | 显示全部楼层
本帖最后由 Nathan 于 2024-11-4 11:49 编辑
论坛管理员 发表于 2024-11-4 10:27
var line = this.form.get("dt1").addLine();   在哪里调用的,截图看看

[AppleScript] 纯文本查看 复制代码
var unitid = this.session.user.identityList[0].unit;     //    获取组织id
var personList1 = this.org.listPersonWithUnit( unitid );     //根据组织id获取人员
console.log("datatable -->" + JSON.stringify(personList1) + "!");
var namesList = [];
//var dataSet = new Set();
for (let i = 0; i < personList1.length; i++) {
    //在这方法里,有true时会主动生成一行行数据,没有时不会主动生成数据行,要手动点“+”号增加行。但人名是有的。
    var promise = this.org.listPersonAllAttribute( personList1,true);
    promise.then(function(attributeObjectList) {
        for (var j = 0; j < attributeObjectList.length; j++) {
            var nl = attributeObjectList[j].name;
            var attributeList = attributeObjectList[j].attributeList;
            console.log("nl-->" + JSON.stringify(nl));
            if (attributeList.includes("company")) {
                console.log("attributeList" + JSON.stringify(attributeList));
                namesList.push(personList1.name);
            }
            console.log("attributeList2" + JSON.stringify(attributeList));
        }
        //在这里执行不会触动创建行
        //var line = this.form.get("datatable").addLine();
    });
     //这里创建行时重复的
        var line = this.form.get("datatable").addLine();
}
回复

使用道具 举报

升级   0.72%

10

主题

11

回帖

72

积分

注册会员

Rank: 2

积分
72
发表于 2024-11-6 09:41:43 | 显示全部楼层
论坛管理员 发表于 2024-11-4 10:27
var line = this.form.get("dt1").addLine();   在哪里调用的,截图看看

您好,您知道怎么去掉datatable的操作列“+-”“箭头”么?打印的时候不允许带着。挺着急的,试了很久不知怎么去掉。我今早发帖子了
回复

使用道具 举报

升级   100%

139

主题

1万

回帖

4万

积分

超级版主

Rank: 8Rank: 8

积分
41458
发表于 2024-11-6 09:41:47 | 显示全部楼层
另一篇帖子里有回复哈
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

联系客服 关注微信 下载APP 返回顶部 返回列表
viewthread