ufo8512 发表于 2022-2-18 09:31:25

流程表单中查询自建数据表数据的问题

请教下,需要在流程表单中通过选择名字查询自建数据表“restdays”的数据,返回到表单中的某一格子里面,照着API编写了语句,都不能运行成功,请教各位,谢谢

var table = new this.Table("restdays");
table.listRowSelect( "o.people = 'this.data.name[0].name'", "o.updateTime desc", 20, function(data){}, function(xhr){});
this.data.explain = data.date


论坛管理员 发表于 2022-2-21 10:07:20

看您的代码是有一点问题的,赋值脚本应该写在调用成功的回调函数里。
您按照这样修改一下再测试,如果还有问题,您可以F12跟踪一下,看看有没有报错,有没有取到date

ufo8512 发表于 2022-2-21 14:11:43

将代码修改为以下形式

var table = new this.Table("restdays");
table.listRowSelect( "o.people = '999'", "o.updateTime desc", 20, this.data.explain = table.data, function(xhr){});
通过F12可以看到查询出的值
{
"type": "success",
"data": [
    {
      "id": "9e325e85-761f-48d4-95ae-4258d188e811",
      "people": "999",
      "days": "999",
      "year": 0,
      "createTime": "2022-02-16 22:58:08",
      "updateTime": "2022-02-16 22:58:08",
      "sequence": "202202162258089e325e85-761f-48d4-95ae-4258d188e811"
    }
],
"message": "",
"date": "2022-02-21 14:07:43",
"spent": 8,
"size": 1,
"count": 0,
"position": 0
}


可还是不懂如何将查询到的     "days": "999",    赋值到单元格



论坛管理员 发表于 2022-2-22 10:03:40

不是,您没理解我的意思,是要把赋值脚本放到调用成功的方法里var table = new this.Table("restdays");
table.listRowSelect( "o.people = '999'", "o.updateTime desc", 20, function(data){this.data.explain = data.days}, function(xhr){});

ufo8512 发表于 2022-2-22 13:04:51

不好意思,现在明白了,但是照上面的写法后,控制台提示如下的错误,但 'explain'这个的名称是没有问题的,是不是函数里面不能这样调用
VM3506:10
      
       Uncaught TypeError: Cannot set properties of undefined (setting 'explain')
    at Object.success (<anonymous>:10:100)
    at Object.onSuccess (<anonymous>:1:46181)
    at Object.i.extend.$owner (mootools-1.6.0_all.js:1399:1)
    at Object._runCallback (o2.js:252:1)
    at Object.onSuccess (o2.js:1614:1)
    at Object.<anonymous> (mootools-1.6.0_all.js:1520:1)
    at Array.forEach (<anonymous>)
    at Function.forEach (mootools-1.6.0_all.js:235:1)
    at Array.each (mootools-1.6.0_all.js:345:1)
    at Object.fireEvent (mootools-1.6.0_all.js:1518:1)

Dffiltri 发表于 2022-2-23 07:19:42

查询成功后的回调函数需要bindthis的指向,在回调函数后加.bind(this),)

Dffiltri 发表于 2022-2-23 07:23:55

function(data){this.data.explain = data.days}.bind(this)

论坛管理员 发表于 2022-2-24 10:49:05

是的呢,不好意思,发您的代码漏掉了bind:(
页: [1]
查看完整版本: 流程表单中查询自建数据表数据的问题