jqPaginator icon indicating copy to clipboard operation
jqPaginator copied to clipboard

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

Open Xluo88 opened this issue 8 years ago • 8 comments

环境信息

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

代码片段:

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

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

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

  • Xluo88 avatar Dec 04 '17 03:12 Xluo88

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

    keenwon avatar Dec 04 '17 03:12 keenwon

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

    Xluo88 avatar Dec 04 '17 03:12 Xluo88

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

    lirenhao avatar Dec 18 '17 07:12 lirenhao

    @lirenhao 因为 totalCounts 不能为空

    keenwon avatar Dec 18 '17 07:12 keenwon

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

    lirenhao avatar Dec 18 '17 07:12 lirenhao

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

    就是这样判断的。

    keenwon avatar Dec 18 '17 07:12 keenwon

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

    lirenhao avatar Dec 18 '17 08:12 lirenhao

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

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

    oncesure avatar Jul 14 '20 05:07 oncesure