0

How do I add bootstrap column widths to the search input box for datatables? Currently I have this:

$("#table_filter input").addClass('form-control input-lg col-xs-12');

However, that does not increase the width of the search input. So far all the other examples have a static width like 350px. I'm hoping to use the column method by Bootstrap.

Edit

var table = $("#table").DataTable({
            "ajax": {
                "url": "@Url.Action("Search", "Users")",
                "type": "POST",
                "data": function (d) {

                },
                "datatype": "json"
            },
            "dom": "f<'col-sm-6'>" ,
            "language": {
                "search": "",
                "searchPlaceholder": "Search"
            },
            "select": {
                "style": 'multi'
            },
            "ordering": true,
            "lengthChange":false,
            "columns": [
                {
                    "data": function (data, type, row, meta) {
                        var url = "@Url.Action("Read","Users")/" + data.Id;
                        return "<a href='" + url + "'>"+data.UserName+"</i></a>"
                    }, "name": "Email"
                },
                { "data": "Email", "name": "Email" },
                { "data": "PhoneNumber", "name": "PhoneNumber" },
            ],
            "processing":true,
            "serverSide": true,
        });
2
  • I think you have an issue in selector for this element can you post you render html for data table Commented Jul 19, 2018 at 13:34
  • Hi I added it. Thank you Commented Jul 19, 2018 at 13:45

1 Answer 1

1

Did you try playing with dom options for datatable, something like this,

< and > - div element
<"class" and > - div with a class
<"#id" and > - div with an ID
<"#id.class" and > - div with an ID and a class
f - filtering input

$('#example').dataTable({
      dom : "<'row' <'col-md-6 pull-right form-group' f>>" 
} );
    //This means <div class='row'><div class="col-md-6 form-group pull-right">filter input </div></div>

please read more here

Sign up to request clarification or add additional context in comments.

3 Comments

Yeah, I currently have lfrtip as the default. I don't really understand how to use it. I'll try your example. Thanks!
Hi, I don't think I understand how this works. I can expand the divs that are above the filter but I can't change its width
Hi @JianYA, I am not sure how to simplify it, the documentation is already very clear, basically you are wrapping your filter input inside divs, read the comments I addedd, please try to go through the documentation and if anything is not clear ask me I am glad to help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.