数据表sDom挑战在表格的左下角添加新元素

数据表sDom挑战在表格的左下角添加新元素

本文介绍了数据表sDom挑战在表格的左下角添加新元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在表格底部的表格中添加一个刷新按钮。但我刚刚开始使用数据表并且它有点令人困惑,因为它是sDom部分,它说我可以通过这种方式做到这一点,但描述最多是模糊的。

I want to add a "refresh" button to my tables at the bottom of the table. But I just started using datatables and its a bit confusing as is the "sDom" part where it says I can do this through that means but the description is vague at best.

"sDom": '<"top"i>rt<"bottom"flp><"clear">'

是datatables.net的例子,但我不知道如何做出正面或反面,我想做的只是一件简单的事情。

is the datatables.net example, but I dunno how to make heads or tails of that and all I want to do is one simple thing.

或者sDom之外是否更适合我想做的事情?

Or is there an outside of "sDom" that would be better suited for what I want to do?

推荐答案

以下是修改后的 sDom 的实例。

Here's a live example of a modified sDom.

这里我们注入 div ,名为< div id =refresh>< / div> 使用structrue <#refresh>

Here we're injecting a div called <div id="refresh"></div> with the structrue <"#refresh">.

    $('#example').dataTable({
        "sDom": '<"top"i>rt<"bottom"<"#refresh">flp><"clear">'
      });

如果您在示例中检查生成的dom,
您可以看到< div id =refresh>< / div> 已插入< div class =bottom>< / div>

If you inspect the generated dom in the example,you can see <div id="refresh"></div> got inserted inside of <div class="bottom"></div>.

我认为很大程度上取决于(1)你的特定表格如何包含其页脚元素,(2)你决定注入你的使用的特定元素,以及(3)如何使用 CSS为元素设置样式

I think much depends on (1) how your specific table has its footer elements layed out, (2) where you decide to inject your specific element using sDom, and (3) how you style the element(s) with your CSS.

或者,您可以在数据表环境之外创建一个按钮,但使用jquery将按钮附加或添加到其中一个按钮dom元素数据表创建。

Alternatively, you could have a button created outside of the datatables environment, but use jquery to append or prepend your button to one of the dom elements datatables creates.

希望这是一个有用的起点。

Hope this is a useful starting point.

这篇关于数据表sDom挑战在表格的左下角添加新元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 00:07