bootstrap-table / How to add filter-control in table configuration

拟墨画扇 提交于 2020-05-16 07:40:28

问题


I'm trying to make a filter per column in Bootstrap-table.

I've seen a lot of sites that use the HTML data-filter-control tag to do this, but I want to do it in the javascript side; preferably on the table configuration attributes.

This is an HTML data-filter-control tag example:

  <thead>
        <tr>
            <th data-field="state" data-checkbox="true"></th>
            <th data-field="prenom" data-filter-control="input" data-sortable="true">Prénom</th>
            <th data-field="date" data-filter-control="select" data-sortable="true">Date</th>
            <th data-field="examen" data-filter-control="select" data-sortable="true">Examen</th>
            <th data-field="note" data-sortable="true">Note</th>
        </tr>
    </thead>

Thank you all!


回答1:


$(function () {
  $('#table').bootstrapTable({
    filterControl: true,
    disableUnusedSelectOptions: true,

    columns: [
      {
        field: "first_column",
        title: "First Column",
        filterControl: 'input',
        filterControlPlaceholder: "holder",
        filterStrictSearch: false
      },{
        field:  "second_column",
        title: "Second Column",
        filterControl: 'select',
        filterStrictSearch: false,
      },
    ]

  });
});


来源:https://stackoverflow.com/questions/46851474/bootstrap-table-how-to-add-filter-control-in-table-configuration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!