Bootstrap-table: formatNoMatches broken?

Created on 1 Mar 2018  路  13Comments  路  Source: wenzhixin/bootstrap-table

I tried following two ways but no one works, what I am doing wrong?
Thanks!

  1. data-formatNoMatches="No Activity"

  2. $tbl.bootstrapTable(
    {
    formatNoMatches: function ()
    {
    return 'No Activity';
    }
    });

help-wanted

All 13 comments

Use the formatnomatches

See this http://jsfiddle.net/jimkennelly/2qbs399z/

@jimgit , like I said, it is not working for me with formatnomatches, not sure why

Setup your code and post on JSFIDDLE - this really helps isolate the problem. Check the console window in Chrome (F12) look for errors. Check that your html & json is properly formatted.

I guess this issue is closed... but How to do it with the data-toggle="table" is on ?

When you added data-toggle="table", the table will bootstrap automatically, and then it doesn鈥檛 work via JavaScript.

Thanks @wenzhixin !
data-formatNoMatches="No Activity" works after removing data-toggle="table"
I am still not very clear, when to use data-toggle="table" and when not to use it?
Thanks!

If you are using it via data attributes you can use data-toggle="table", and if you want to using it via JavaScript you need to remove data-toggle="table". Because our code will check whether the table has data-toggle="table" attribute and yes, it will call $('#table').bootstrapTable({}) automatically.

http://bootstrap-table.wenzhixin.net.cn/getting-started/

Via data attributes

Activate bootstrap table without writing JavaScript. Set data-toggle="table" on a normal table.

<table data-toggle="table">
    <thead>
        <tr>
            <th>Item ID</th>
            <th>Item Name</th>
            <th>Item Price</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>1</td>
            <td>Item 1</td>
            <td>$1</td>
        </tr>
        <tr>
            <td>2</td>
            <td>Item 2</td>
            <td>$2</td>
        </tr>
    </tbody>
</table>

Via JavaScript

Call a bootstrap table with id table with JavaScript.

<table id="table"></table>
````

$('#table').bootstrapTable({
columns: [{
field: 'id',
title: 'Item ID'
}, {
field: 'name',
title: 'Item Name'
}, {
field: 'price',
title: 'Item Price'
}],
data: [{
id: 1,
name: 'Item 1',
price: '$1'
}, {
id: 2,
name: 'Item 2',
price: '$2'
}]
});
```

Hi @wenzhixin , I always populate my table using JavaScript, like $('#table').bootstrapTable('load', parameter); so I should not use data-toggle="table", correct?
Again, thanks!

$('#table').bootstrapTable('load', parameter); is a method, before using it you need to use data-toggle="table" or $('#table').bootstrapTable();.

Got it. Thanks @wenzhixin

I had different approach to load data, ie, I was using $('#table').bootstrapTable({data: jsonData}) and needed to add data-toggle="table" so that some columns of my data can be sorted.

I will look again the doc, for further reading... Thanks @wenzhixin for all.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iamthestreets picture iamthestreets  路  26Comments

antonioaltamura picture antonioaltamura  路  15Comments

marcelod picture marcelod  路  16Comments

cgountanis picture cgountanis  路  14Comments

thongkekienthuc12 picture thongkekienthuc12  路  16Comments