Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

设置 totalCounts 为 0 时,会提示该值是必填项。 #30

Open
Xluo88 opened this issue Dec 4, 2017 · 8 comments
Open

设置 totalCounts 为 0 时,会提示该值是必填项。 #30

Xluo88 opened this issue Dec 4, 2017 · 8 comments

Comments

@Xluo88
Copy link

Xluo88 commented Dec 4, 2017

环境信息

  • 系统: Window 7
  • 浏览器及其版本: Chrome 54

代码片段:

$("#tablePagination").jqPaginator({
totalCounts: 0,
pageSize: globalProperty.pageSize,
visiblePages: 10,
currentPage: globalProperty.pageIndex_default,
first: '

  • 首页</a></li>',
    prev: '
  • 上一页</a></li>',
    next: '
  • 下一页</a></li>',
    last: '
  • 末页 [总记录数:{{totalCounts}}]</a></li>',
    page: '
  • {{page}}</a></li>',
    onPageChange: function (currentPageIndex) {
    //getData({
    // currentPageIndex: currentPageIndex,
    // fieldName: globalProperty.sort_fieldName,
    // fieldOrder: globalProperty.sort_fieldOrder
    //});
    }
    });

    我觉得设置 totalCounts 为 0 应当是合理的,毕竟来自服务端的记录总有为 0 条的情形。

  • @keenwon
    Copy link
    Owner

    keenwon commented Dec 4, 2017

    目前的分页逻辑,没有考虑这种情况,因为 totalCounts 为 0 的时候,是不该显示 jqPaginator 分页

    @Xluo88
    Copy link
    Author

    Xluo88 commented Dec 4, 2017

    不该显示是吧?是我自己先判断记录总数为 0 在情形下,采用诸如 hide() 方法去隐藏分页栏吗?
    如果是,能否考虑在插件的内部实现一下这个逻辑?

    @lirenhao
    Copy link

    当totalCounts 为 0 的时候,分页是不显示,但是在控制台会打印totalCounts不能为空的错误

    @keenwon
    Copy link
    Owner

    keenwon commented Dec 18, 2017

    @lirenhao 因为 totalCounts 不能为空

    @lirenhao
    Copy link

    当totalCounts 为 0 的时候,还是报[jqPaginator] totalCounts or totalPages is required

    @keenwon
    Copy link
    Owner

    keenwon commented Dec 18, 2017

    if (!opts.totalPages && !opts.totalCounts) {
      throw new Error('[jqPaginator] totalCounts or totalPages is required');
    }

    就是这样判断的。

    @lirenhao
    Copy link

    这是错误的,当totalPages或totalCounts等于0时, (!opts.totalPages && !opts.totalCounts)是true

    @3344567
    Copy link

    3344567 commented Jul 14, 2020

    当totalCounts为0的时候,还是报[jqPaginator] totalCounts或totalPages

    我认为应该在下列选项中选择一个:
    1.error改成log
    2.插件中处理这种情况
    最好是选择第二种
    因为这是用jq实现的,并且没有init方法,作为强迫症,控制台报错.....

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants