responsetotals-undefinedplease-check-totalsKey

在使用GridManager的时候,有时会出现以下错误:

GridManager Error: response.totals undefined,please check totalsKey

解决方法
这个错误是由于的返回的数据中未找到totals字段,并提示检查配置项totalsKey

如果totalsKey与接口返回字段不匹配,那么组件通过totalsKey获取到的将是undefined

比如接口返回格式如下:

{
    list: [
    {name:'baukh', age: 11},
    {name:'baukh2', age: 22}
    ],
    sum: 2
}

由于totalsKey默认值为totals,当接口返回的总条数字段为sum时就需要在初始化时添加配置项: totalsKey: 'sum'

详情可参考API – totalsKey

如果当前未配置totalsKey: 'sum',将会报出GridManager Error: response.totals undefined,please check totalsKey错误。

除此之外配置项responseHandler也可以处理该问题,但responseHandler一般用于处理更为复杂的情况。

详情可参考API – responseHandler

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理