我如何在bootstrapTable中添加额外的属性

时间:2016-05-01 23:54:14

标签: javascript jquery twitter-bootstrap datatables bootstrap-table

我使用了bootstrapTable.js插件 https://github.com/wenzhixin/bootstrap-table 创建数据表,我填写Json

但是我需要控制我的td标签,因为在td标签中添加了一些额外的属性 正如我在我的代码中写的那样#34; data-symbole"属性 ,但插件删除它 请有人帮帮我吗



var x = 
[
    {
        "id": 0,
        "name": "test0",
        "price": "$0"
        ,"pricesymbole":"$"
    },
    {
        "id": 1,
        "name": "test1",
        "price": "$1"
      ,"pricesymbole":"$"
    },
    {
        "id": 2,
        "name": "test2",
        "price": "$2"
      ,"pricesymbole":"$"
    },
    {
        "id": 3,
        "name": "test3",
        "price": "$3"
      ,"pricesymbole":"$"
    }
];

$(function () {
    $('#table').bootstrapTable({
        data: x
    });
});

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">

<!-- Latest compiled and minified CSS -->


<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.10.1/bootstrap-table.min.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

<script src="http://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.10.1/bootstrap-table.min.js"></script>

<table id="table">
    <thead>
        <tr id="tr_{{id}}">
            <th data-field="id">Item ID</th>
            <th data-field="name">Item Name</th>
            <th data-field="price" data-symbole="pricesymbole">Item Price</th>
        </tr>
    </thead>
</table>
        
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

我认为@echo off ROBOCOPY "H:\Laptop-Backup" "E:\Laptop-Backup" /s rem /e: Include directories and sub directories even if empty REM /s Copy Subdirectories, but not empty ones. 选项在您的情况下非常有用:

&#13;
&#13;
formatter
&#13;
var x = 
[
    {
        "id": 0,
        "name": "test0",
        "price": "0"
        ,"pricesymbole":"$ "
    },
    {
        "id": 1,
        "name": "test1",
        "price": "1"
      ,"pricesymbole":"¥"
    },
    {
        "id": 2,
        "name": "test2",
        "price": "2"
      ,"pricesymbole":"$ "
    },
    {
        "id": 3,
        "name": "test3",
        "price": "3"
      ,"pricesymbole":"¥"
    }
];

$(function () {
    $('#table').bootstrapTable({
        data: x
    });
});

function priceFormatter(value, row) {
    return row.pricesymbole + value;
}
&#13;
&#13;
&#13;