添加新行后无法“刷新”灯丝组表锯响应表

can't "refresh" filamentgroup tablesaw responsive table after adding new rows

本文关键字:响应 刷新 新行 添加      更新时间:2023-09-26

我正在使用AngularJS Utils分页指令和filamentgroup tablesaw响应式表库的组合来尝试获得响应式(通过向右滑动)分页表。

填充表后,我从另一个称为响应表的指令中调用表锯"刷新"事件,它使表完全响应,并且世界一切都很好。

$("tableselector").table("refresh")

但是,当我更改页面(因此表中的行更改)时,表停止响应(如果您检查 HTML,我可以看到新行在"tr"元素上没有相关的表锯类,而"th"元素仍然有)。

我有点预料到这一点,并尝试再次调用刷新事件,但这不起作用,所以我尝试了销毁事件,这似乎也不起作用!

以下是我的 HTML 供参考。

<table class="table table--stripe" data-mode="swipe" responsive-table>
  <thead>
    <tr>
      <th>Email</th>
      <th>Name</th>
      <th>User role</th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <tr dir-paginate="user in Model.Users | itemsPerPage:Model.PageSize" current-page="Model.CurrentPage">
      <td>{{user.Email}}</td>
      <td>{{user.DisplayName}}</td>
      <td>{{user.Role}}</td>
      <td>{{user.Telephone}}</td>
    </tr>
  </tbody>
</table>

我已经大致找到了表锯代码似乎"错误"的地方(尽管我怀疑这只是我缺乏理解)

 $.fn[pluginName] = function ()
    {
        return this.each(function ()
        {
            var $t = $(this);
            if ($t.data(pluginName))
            {
                return;
            }
            var table = new Table(this);
            $t.data(pluginName, table);
        });
    };

浏览了大量表锯代码后,我发现上面的代码总是在插入新行并调用刷新、销毁甚至创建事件后通过 return 语句退出。

是否有其他人遇到这些问题,或者知道如果我错误地使用任一库来刷新/销毁/重新创建响应式表,该怎么办?

所以我在

GitHub 上被 https://github.com/zachleat 善意地指出了正确的方向。

我不得不稍微更改在用户单击移动到下一个分页页面后刷新表的代码行。

$('#mytable').table().data("table").refresh()

只是因为在调用 refresh() 之前加载了 tbody>tr>td。这是偶然的。刷新函数不调用截图$cells.wrapInner( " );$cells.prepend( " + html + " );"

您可以更改源代码。 使用 Init 事件 Instand of Refresh 事件。