具有固定列的数据表中的可排序图标错误

时间:2018-07-05 14:54:07

标签: javascript jquery css datatables

我在这里是因为我在使用Datatables中的fixedColumns插件时遇到了问题

问题是我设置的列(左侧的第一列)不应该排序,但是,该表的生成是在th处带有“ sort”图标,并且当该表按另一列排序,因为主列的图标(不应排序)在左侧消失,所以会产生冲突

这就是我正在尝试的

HTML

<table id="demoGrid" class="display table table-striped table-bordered nowrap" cellspacing="0" cellpadding="0" style="width:100%;">
    <thead>
        <tr>
            @*<th>Acción</th>*@
            <th>Código Delfos</th>
            <th>Cliente</th>
            <th>NotaDeVenta</th>
            <th>Potencia</th>
            <th>TensionNominalMayor</th>
            <th>TensionNominalMenor</th>
            <th>MaterialTensionMayor</th>
            <th>MaterialTensionMenor</th>
            <th>GrupoDeConexiones</th>
            <th>Regulacion</th>
            <th>Frecuencia</th>
            <th>Norma</th>
            <th>Marca</th>
            <th>Tipo</th>
        </tr>
    </thead>
    <tbody></tbody>

</table>

JavaScript

var table = $('#demoGrid').DataTable
({
    processing: true, // for show progress bar
    serverSide: true, // for process server side
    filter: true, // this is for disable filter (search box)
    orderMulti: false, // for disable multiple column at once
    pageLength: 5,
    colReorder:
        {
            fixedColumnsLeft: 1
        },
    fixedColumns:
        {
            leftColumns: 1,
        },
    ajax: 
        {
        "url": '@Url.Action("Cargar")',
        "type": "POST",
        "datatype": "json",
        "data": function (d) 
            {
                d.filtros = filtros;
            }
        },
    "columns": 
        [
            { "data": "Codigo_delfos", "name": "Codigo_delfos", "autoWidth": true, orderable: false},
            { "data": "Cliente", "name": "Cliente"},
            { "data": "NotaDeVenta", "name": "NotaDeVenta" },
            { "data": "Potencia", "name": "Potencia" },
            { "data": "TensionNominalMayor", "name": "TensionNominalMayor", render: function (data, type, row, meta) { return (data + "").replace('.', ',') }  },
            { "data": "TensionNominalMenor", name: "TensionNominalMenor", render: function (data, type, row, meta) { return (data+"").replace('.',',')} },
            { "data": "MaterialTensionMayor", name: "MaterialTensionMayor" },
            { "data": "MaterialTensionMenor", name: "MaterialTensionMenor" },
            { "data": "GrupoDeConexiones", name: "GrupoDeConexiones" },
            { "data": "Regulacion", name: "Regulacion" },
            { "data": "Frecuencia", name: "Frecuencia" },
            { "data": "Norma", name: "Norma" },
            { "data": "Marca", name: "Marca" },
            { "data": "TipoDeTransformador", name: "TipoDeTransformador"}
        ],
    scrollX: true,
    scrollCollapse: true,
    dom:
    "<'row'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'>>" +
    "<'row'<'col-sm-12'tr>>" +
    "<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>"

});

添加一张图片,清楚地说明问题所在

enter image description here

使用colReorderfixedColumns(或同时使用两者)修复列时会产生问题

有人知道我该如何解决?

非常感谢!

0 个答案:

没有答案