jQuery Datatable.js排序和搜索功能

时间:2018-11-14 16:58:01

标签: jquery datatables neoscms

我当前正在使用NEOS CMS,并且在我的网站上有很多表是由编辑人员直接使用后端添加的,不需要任何代码。现在需要通过jquery datatable插件对表进行排序。问题在于该插件要求表具有thead标记以标识表头。像下面一样

<table>
    <thead>
      <tr>
        <th>Column 1</th>
        <th>Column 2</th>
      </tr>
    </thead>
    <tbody>
    <tr>
      <td>Data1</td>
      <td>Data2</td>
    </tr>
    <tbody> 

</table>

但NEOS CMS以以下格式创建表

    <table>
        <tbody>
          <tr>
            <th>Column 1</th>
            <th>Column 2</th>
          </tr>
        <tr>
          <td>Data1</td>
          <td>Data2</td>
        </tr>
        <tbody> 

    </table>

因此,jQuery无法找到thead,因此无法正常工作。我的问题是,插件中是否有针对此问题的解决方法,因此它可以与格式一起使用。还是其他所有像datatables一样的javascript库?

谢谢。

1 个答案:

答案 0 :(得分:1)

在新的用户界面中,您可以启用CK编辑器5。您可以在表中设置更多属性,例如head等。

我做了简短测试,得到了以下代码:

<table>
    <thead>
        <tr>
            <th scope="col">test</th>
            <th scope="col">test</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Entry</td>
            <td>Entry</td>
        </tr>
        <tr>
            <td>Entry</td>
            <td>Entry</td>
        </tr>
    </tbody>
</table>

以下是有关Neos和编辑的简短文章: https://www.neos.io/blog/neos-is-in-love-with-ckeditor5.html

您知道吗,Neos既有自己的话语又有懈怠?在这里,您会找到所有链接: https://www.neos.io/docs-and-support/support.html