格式化DataTables标头中的问题

时间:2013-09-02 19:06:56

标签: javascript jquery html css jquery-datatables

我正在尝试在我的数据表网格的标题中添加一些额外的元素,除了搜索框被撞到一行之外,所有元素都正常工作。如何使单选按钮居中,并使搜索框显示在与其余按钮相同的行上?它是否与<“Clear”>?

有关

这是JS:

$(document).ready(function () {

    var tbl = $('#EACApprovalGrid').dataTable({
        "bProcessing": true,
        "bDeferRender": true,
        "oLanguage": {
            "sSearch": "Search:",
        },
        "iDisplayLength": 25,
        "bStateSave": false,
        "sPaginationType": "full_numbers",
        "aaSorting": [[5, "asc"]],
        "sDom": '<"top"l<"EacEcrRadioRegion">f>rt<"bottom"p<"clear">>'
    });


    var btns = '<input type="radio" class="EacEcrSelection" name="EacEcrSelection" id="EacRadio" value="EAC" /> EAC&nbsp;&nbsp;&nbsp;'
            + '<input type="radio" class="EacEcrSelection" name="EacEcrSelection" id="EcrRadio" value="ECR" /> ECR&nbsp;&nbsp;&nbsp;'
            + '<input type="radio" class="EacEcrSelection" name="EacEcrSelection" id="BothRadio" value="Both" /> Both'
    $(".EacEcrRadioRegion").html(btns);


    $('#EacRadio').click(function() {tbl.fnFilter("EAC",0);});
    $('#EcrRadio').click(function() {tbl.fnFilter("ECR",0);});
    $('#BothRadio').click(function() {tbl.fnFilter("",0);});

});

这是一个小提琴:http://jsfiddle.net/7KkpQ/3/

这是截图http://imgur.com/1N6ABtP   (在你问之前 - 是的,它发生在IE,FF和Chrome中)

1 个答案:

答案 0 :(得分:0)

这可能非常接近: http://jsfiddle.net/7KkpQ/9/

额外的CSS如下:

.EacEcrRadioRegion {
    text-align: center;
    float: left;
    width: 50%;
}

#example_filter {   
    float: right;
}