【问题标题】:how to display default icons when sorting in datatables bootstrap在数据表引导程序中排序时如何显示默认图标
【发布时间】:2016-01-27 06:19:09
【问题描述】:

我在引导程序中使用数据表,但图表中的默认图标不显示, datatables official website 上有例子

我要显示的是默认图标如下:

描述: asc:

图表应该是这样的:

但它实际上是这样显示的:

我使用PHP插入datables javascript和css的链接,我自定义的css或javascript函数是否存在错误导致这个问题?

$('#table-sort').DataTable({
        paging: false,
        searching: false,
        info: false,
        "order":[[2,"desc"]],
        "columnDefs":[{
            "orderable":false,
            "targets":[0,1]
        }]
    });
<table class="table table-hover table-striped table-bordered compact table-sorting dataTable" id="table-sort" cellspacing="0" role="grid">
    <thead>
        <tr>
            <th>username</th>
            <th>description</th>
            <th id="closing_date" style="cursor: pointer">deadline</th>
            <th id="update_date" style="cursor: pointer">update</th>
            <th>action</th>
        </tr>
    </thead>
  </table>

感谢大家耐心阅读我的问题,如果有人提供任何解决方案,我将不胜感激。

【问题讨论】:

  • 请检查您的控制台是否有任何错误显示?
  • 对不起,我检查了控制台,但没有显示错误。
  • 为什么有些选项只有双引号?,检查一下
  • 我无法检查您的编码,请将您的编码放在 jsfiddle 或其他中
  • 谢谢你,我才发现是我添加css的方法出错了!我应该通过 标签而不是使用 PHP 来链接样式表!这使得浏览器在引导样式表之前加载 jquery.css !无论如何,谢谢你抽出时间来帮助我!

标签: javascript jquery css twitter-bootstrap datatables


【解决方案1】:

很抱歉发现是我加载样式表的方法导致了这个问题,
我应该使用 &lt;link&gt; 标签来加载 jquery 样式表而不是 PHP


我之前加载文件的方式如下

&lt;?php Yii::app()-&gt;clientScript-&gt;registerCssFile(Yii::app()-&gt;baseUrl . "/common/css/dataTables.bootstrap.min.css", CClientScript::POS_HEAD);?&gt;

在我更改加载方法后它工作正常

&lt;link rel="stylesheet" type="text/css" href="&lt;?php echo zmf::config('baseurl');?&gt;/common/css/dataTables.bootstrap.min.css"&gt;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多