文檔閱讀

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!--<link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/bootstrap-table.min.css">
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <!--<script src="assets/bootstrap2.3/js/bootstrap.min.js"></script>-->
    <!--<script src="js/tableExport.js"></script>
    <script src="js/jquery.base64.js"></script>
    <script src="js/bootstrap-table.js"></script>-->
    <!--<script src="js/bootstrap-table-export.js"></script>-->
    <link rel="stylesheet" type="text/css" href="css1/bootstrap-table.css" />
    <link rel="stylesheet" type="text/css" href="css1/bootstrap.min.css" />
    <script src="js1/jquery.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="js1/bootstrap-table.js" type="text/javascript" charset="utf-8"></script>
    <script src="js1/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="js1/bootstrap-table-zh-CN.js" type="text/javascript" charset="utf-8"></script>
    <!--<script src="js/bootstrap-table-zh-CN.js" type="text/javascript" charset="utf-8"></script>-->
    <style type="text/css">
        .wd{
            width: 16px;
        }
    </style>
    <script type="text/javascript">
        var a = [{
                "id": 0,
                "name": "阿薩德",
                "price": "<a href='#'>![](./刪除.png)</a>"
            },
            {
                "id": 1,
                "name": "Item 1",
                "price": "$1"
            },
            {
                "id": 2,
                "name": "Item 2",
                "price": "$2"
            },
            {
                "id": 3,
                "name": "Item 3",
                "price": "$3"
            },
            {
                "id": 4,
                "name": "Item 4",
                "price": "$4"
            },
            {
                "id": 5,
                "name": "Item 5",
                "price": "$5"
            },
            {
                "id": 6,
                "name": "Item 6",
                "price": "$6"
            },
            {
                "id": 7,
                "name": "Item 7",
                "price": "$7"
            },
            {
                "id": 8,
                "name": "Item 8",
                "price": "$8"
            },
            {
                "id": 9,
                "name": "Item 9",
                "price": "$9"
            },
            {
                "id": 10,
                "name": "Item 10",
                "price": "$10"
            },
            {
                "id": 11,
                "name": "Item 11",
                "price": "$11"
            },
            {
                "id": 12,
                "name": "Item 12",
                "price": "$12"
            },
            {
                "id": 13,
                "name": "Item 13",
                "price": "$13"
            },
            {
                "id": 14,
                "name": "Item 14",
                "price": "$14"
            },
            {
                "id": 15,
                "name": "Item 15",
                "price": "$15"
            },
            {
                "id": 16,
                "name": "Item 16",
                "price": "$16"
            },
            {
                "id": 17,
                "name": "Item 17",
                "price": "$17"
            },
            {
                "id": 18,
                "name": "Item 18",
                "price": "$18"
            },
            {
                "id": 19,
                "name": "Item 19",
                "price": "$19"
            },
            {
                "id": 20,
                "name": "Item 20",
                "price": "$20"
            },
            {
                "id": 0,
                "name": "阿薩德",
                "price": "<a href='#' id='btn'>修改</a>"
            },
            {
                "id": 1,
                "name": "Item 1",
                "price": "$1"
            },
            {
                "id": 2,
                "name": "Item 2",
                "price": "$2"
            },
            {
                "id": 3,
                "name": "Item 3",
                "price": "$3"
            },
            {
                "id": 4,
                "name": "Item 4",
                "price": "$4"
            },
            {
                "id": 5,
                "name": "Item 5",
                "price": "$5"
            },
            {
                "id": 6,
                "name": "Item 6",
                "price": "$6"
            },
            {
                "id": 7,
                "name": "Item 7",
                "price": "$7"
            },
            {
                "id": 8,
                "name": "Item 8",
                "price": "$8"
            },
            {
                "id": 9,
                "name": "Item 9",
                "price": "$9"
            },
            {
                "id": 10,
                "name": "Item 10",
                "price": "$10"
            },
            {
                "id": 11,
                "name": "Item 11",
                "price": "$11"
            },
            {
                "id": 12,
                "name": "Item 12",
                "price": "$12"
            },
            {
                "id": 13,
                "name": "Item 13",
                "price": "$13"
            },
            {
                "id": 14,
                "name": "Item 14",
                "price": "$14"
            },
            {
                "id": 15,
                "name": "Item 15",
                "price": "$15"
            },
            {
                "id": 16,
                "name": "Item 16",
                "price": "$16"
            },
            {
                "id": 17,
                "name": "Item 17",
                "price": "$17"
            },
            {
                "id": 18,
                "name": "Item 18",
                "price": "$18"
            },
            {
                "id": 19,
                "name": "Item 19",
                "price": "$19"
            },
            {
                "id": 20,
                "name": "Item 20",
                "price": "$20"
            },
            {
                "id": 0,
                "name": "阿薩德",
                "price": "<a href='#' id='btn'>修改</a>"
            },
            {
                "id": 1,
                "name": "Item 1",
                "price": "$1"
            },
            {
                "id": 2,
                "name": "Item 2",
                "price": "$2"
            },
            {
                "id": 3,
                "name": "Item 3",
                "price": "$3"
            },
            {
                "id": 4,
                "name": "Item 4",
                "price": "$4"
            },
            {
                "id": 5,
                "name": "Item 5",
                "price": "$5"
            },
            {
                "id": 6,
                "name": "Item 6",
                "price": "$6"
            },
            {
                "id": 7,
                "name": "Item 7",
                "price": "$7"
            },
            {
                "id": 8,
                "name": "Item 8",
                "price": "$8"
            },
            {
                "id": 9,
                "name": "Item 9",
                "price": "$9"
            },
            {
                "id": 10,
                "name": "Item 10",
                "price": "$10"
            },
            {
                "id": 11,
                "name": "Item 11",
                "price": "$11"
            },
            {
                "id": 12,
                "name": "Item 12",
                "price": "$12"
            },
            {
                "id": 13,
                "name": "Item 13",
                "price": "$13"
            },
            {
                "id": 14,
                "name": "Item 14",
                "price": "$14"
            },
            {
                "id": 15,
                "name": "Item 15",
                "price": "$15"
            },
            {
                "id": 16,
                "name": "Item 16",
                "price": "$16"
            },
            {
                "id": 17,
                "name": "Item 17",
                "price": "$17"
            },
            {
                "id": 18,
                "name": "Item 18",
                "price": "$18"
            },
            {
                "id": 19,
                "name": "Item 19",
                "price": "$19"
            },
            {
                "id": 20,
                "name": "Item 20",
                "price": "$20"
            },
            {
                "id": 0,
                "name": "阿薩德",
                "price": "<a href='#' id='btn'>修改</a>"
            },
            {
                "id": 1,
                "name": "Item 1",
                "price": "$1"
            },
            {
                "id": 2,
                "name": "Item 2",
                "price": "$2"
            },
            {
                "id": 3,
                "name": "Item 3",
                "price": "$3"
            },
            {
                "id": 4,
                "name": "Item 4",
                "price": "$4"
            },
            {
                "id": 5,
                "name": "Item 5",
                "price": "$5"
            },
            {
                "id": 6,
                "name": "Item 6",
                "price": "$6"
            },
            {
                "id": 7,
                "name": "Item 7",
                "price": "$7"
            },
            {
                "id": 8,
                "name": "Item 8",
                "price": "$8"
            },
            {
                "id": 9,
                "name": "Item 9",
                "price": "$9"
            },
            {
                "id": 10,
                "name": "Item 10",
                "price": "$10"
            },
            {
                "id": 11,
                "name": "Item 11",
                "price": "$11"
            },
            {
                "id": 12,
                "name": "Item 12",
                "price": "$12"
            },
            {
                "id": 13,
                "name": "Item 13",
                "price": "$13"
            },
            {
                "id": 14,
                "name": "Item 14",
                "price": "$14"
            },
            {
                "id": 15,
                "name": "Item 15",
                "price": "$15"
            },
            {
                "id": 16,
                "name": "Item 16",
                "price": "$16"
            },
            {
                "id": 17,
                "name": "Item 17",
                "price": "$17"
            },
            {
                "id": 18,
                "name": "Item 18",
                "price": "$18"
            },
            {
                "id": 19,
                "name": "Item 19",
                "price": "$19"
            },
            {
                "id": 20,
                "name": "Item 20",
                "price": "$20"
            }
        ]
    </script>
</head>
<style type="text/css">
    .aa{
        background-color: red;
    }
</style>
<body>
    <div class="container">
        <!--<div>
            <label>Cells: </label><input id="cells" type="text" placeholder="Cells" value="5">
            <label>Rows: </label><input id="rows" type="text" placeholder="Rows" value="100">
            <button id="build" class="btn btn-default">Build</button>
        </div>-->
        <!--
            data-toggle="table"  不用寫(xiě) JavaScript 直接啟用表格追迟。
            data-classes='table-no-bordered    消除邊框
        -->
        <table id="table" data-show-columns="true" data-search="true" data-show-refresh="true" data-show-toggle="true" data-pagination="true" data-show-pagination-switch="true" data-height="500" data-show-header="true" data-striped='true' data-pagination-pre-text="上一頁(yè)" data-pagination-next-text='下一頁(yè)'>
            <thead>
                <tr>
                    <th data-field="state" data-checkbox="true"></th>
                    <th data-field="id" data-formatter="idFormatter" data-stripe="true">ID</th>
                    <th data-field="name">Item Name</th>
                    <th data-field="price" id="item" data-icons={paginationSwitchDown: 'glyphicon-collapse-down icon-chevron-down'}>Item Price</th>
                </tr>
            </thead>
            <button id="btn">提交</button>
            <button id="btn1">提交1</button>
        </table>

    </div>
    <script>
        function idFormatter(value) {
            return value + 100;
        }

        $('#table').bootstrapTable({
            data: a
        });
        $(function() {
            $("#btn").click(function() {
                var ids = $.map($('#table').bootstrapTable('getSelections'), function(row) {
                    return row;
                });
                alert('您選擇的id是: ' + JSON.stringify(ids));
            });
            //刪除哪里行

// $("#btn1").click(function() {
// $('#table').bootstrapTable('removeByUniqueId', 1);
// });

        })
        
        // 全局判斷

// $('#table').on('click-row.bs.table', function(e, row, element) {
// var bln = window.confirm("確定嗎?");
// console.log(row.id)
// if(bln)
//// $('#table').bootstrapTable('removeByUniqueId', {index: row.id});
// $('#table').bootstrapTable('hideRow', {index: row.id});
//
// $('.aa').removeClass('aa'); //去除之前選中的行的瘾敢,選中樣式
// $(element).addClass('aa'); //添加當(dāng)前選中的 success樣式用于區(qū)別
// console.log($(element));
// });

    //針對(duì)列進(jìn)行判斷
        $('#table').on('click-cell.bs.table', function(field, value, row, $element) { 

// var bln = window.confirm("確定嗎?");
// console.log(row.id)
// if(bln)
//// $('#table').bootstrapTable('removeByUniqueId', {index: row.id});
// $('#table').bootstrapTable('hideRow', {index: row.id});
//
// $('.aa').removeClass('aa'); //去除之前選中的行的排吴,選中樣式
// $(element).addClass('aa'); //添加當(dāng)前選中的 success樣式用于區(qū)別
console.log($element);
console.log(field);
console.log(value);
console.log(row);
// alert(1);
});

        function getSelectedRow() { 
            var index = $('#teacher_table').find('tr.success').data('index'); //獲得選中的行
             
            return $('#teacher_table').bootstrapTable('getData')[index]; //返回選中行所有數(shù)據(jù)
        }

        /// 指定的行 顯示或隱藏
        //  $(function () {
        //      $("#btn1").click(function () {
        //          $('#table').bootstrapTable('showRow', {index: 1});
        //      });
        //
        //     $("#btn1").click(function () {
        //          $('#table').bootstrapTable('hideRow', {index: 1});
        //      });
        //  });
        //          

        // updateRow 更新指定行的數(shù)據(jù)
        //          $(function() {
        //              $("#btn1").click(function() {
        //                  var randomId = 100 + ~~(Math.random() * 100);
        //                  $('#table').bootstrapTable('updateRow', {
        //                      index: 1,
        //                      row: {
        //                          id: randomId,
        //                          name: 'Item ' + randomId,
        //                          price: '$' + randomId
        //                      }
        //                  });
        //              });
        //          });

        // 插入指定行之前 index是 id索引
        //  $(function () {
        //      $("#btn1").click(function () {
        //          var randomId = 100 + ~~(Math.random() * 100);
        //          $('#table').bootstrapTable('insertRow', {
        //              index: 0,
        //              row: {
        //                  id: randomId,
        //                  name: 'Item ' + randomId,
        //                  price: '$' + randomId
        //              }
        //          });
        //      });
        //  });

        //插入數(shù)據(jù)到尾部  append  頭部 prepend
        //          $(function() {
        //              $("#btn1").click(function() {
        //                  $('#table').bootstrapTable('prepend', randomData());
        //                  $('#table').bootstrapTable('scrollTo', 'top');
        //              });
        //          });
        //
        //          function randomData() {
        //              var startId = ~~(Math.random() * 100),
        //                  rows = [];
        //
        //              for(var i = 0; i < 1; i++) {
        //                  rows.push({
        //                      id: startId + i,
        //                      name: 'test' + (startId + i),
        //                      price: '$' + (startId + i)
        //                  });
        //              }
        //              return rows;
        //          }

        //隨機(jī)數(shù)據(jù)
        //              $("#btn1").click(function() {
        //                  $("#table").bootstrapTable('load', randomData());
        //              });
        //          function randomData() {
        //              var startId = ~~(Math.random() * 100),
        //                  rows = [];
        //
        //              for(var i = 0; i < 10; i++) {
        //                  rows.push({
        //                      id: startId + i,
        //                      name: 'test' + (startId + i),
        //                      price: '$' + (startId + i)
        //                  });
        //              }
        //              return rows;
        //          }
    </script>
</body>

</html>

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市灵迫,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌聘裁,老刑警劉巖赴叹,帶你破解...
    沈念sama閱讀 212,454評(píng)論 6 493
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件不翩,死亡現(xiàn)場(chǎng)離奇詭異兵扬,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)口蝠,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,553評(píng)論 3 385
  • 文/潘曉璐 我一進(jìn)店門(mén)器钟,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人妙蔗,你說(shuō)我怎么就攤上這事傲霸。” “怎么了眉反?”我有些...
    開(kāi)封第一講書(shū)人閱讀 157,921評(píng)論 0 348
  • 文/不壞的土叔 我叫張陵昙啄,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我寸五,道長(zhǎng)梳凛,這世上最難降的妖魔是什么? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 56,648評(píng)論 1 284
  • 正文 為了忘掉前任梳杏,我火速辦了婚禮韧拒,結(jié)果婚禮上淹接,老公的妹妹穿的比我還像新娘。我一直安慰自己叛溢,他們只是感情好塑悼,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,770評(píng)論 6 386
  • 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著楷掉,像睡著了一般厢蒜。 火紅的嫁衣襯著肌膚如雪挺庞。 梳的紋絲不亂的頭發(fā)上新症,一...
    開(kāi)封第一講書(shū)人閱讀 49,950評(píng)論 1 291
  • 那天缺狠,我揣著相機(jī)與錄音丈挟,去河邊找鬼眼姐。 笑死尉姨,一個(gè)胖子當(dāng)著我的面吹牛我擂,可吹牛的內(nèi)容都是我干的择吊。 我是一名探鬼主播促绵,決...
    沈念sama閱讀 39,090評(píng)論 3 410
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼攒庵,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了败晴?” 一聲冷哼從身側(cè)響起浓冒,我...
    開(kāi)封第一講書(shū)人閱讀 37,817評(píng)論 0 268
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎尖坤,沒(méi)想到半個(gè)月后稳懒,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 44,275評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡慢味,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,592評(píng)論 2 327
  • 正文 我和宋清朗相戀三年场梆,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片纯路。...
    茶點(diǎn)故事閱讀 38,724評(píng)論 1 341
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡或油,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出驰唬,到底是詐尸還是另有隱情顶岸,我是刑警寧澤,帶...
    沈念sama閱讀 34,409評(píng)論 4 333
  • 正文 年R本政府宣布叫编,位于F島的核電站辖佣,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏搓逾。R本人自食惡果不足惜卷谈,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 40,052評(píng)論 3 316
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望恃逻。 院中可真熱鬧雏搂,春花似錦藕施、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 30,815評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至芙沥,卻和暖如春诲祸,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背而昨。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 32,043評(píng)論 1 266
  • 我被黑心中介騙來(lái)泰國(guó)打工救氯, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人歌憨。 一個(gè)月前我還...
    沈念sama閱讀 46,503評(píng)論 2 361
  • 正文 我出身青樓着憨,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親务嫡。 傳聞我的和親對(duì)象是個(gè)殘疾皇子甲抖,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,627評(píng)論 2 350

推薦閱讀更多精彩內(nèi)容

  • 官方文檔目錄 優(yōu)化select語(yǔ)句 原文 查詢(xún)語(yǔ)句作為最常用類(lèi)型的語(yǔ)句,其優(yōu)化價(jià)值理所當(dāng)然是最大的心铃。 優(yōu)化查詢(xún)語(yǔ)句...
    walker_liu_fei閱讀 690評(píng)論 0 0
  • REST 通過(guò)services路徑的RESTful接口准谚,可以把服務(wù)接口暴露出去。 也就是說(shuō)可以通過(guò)HTTP方法來(lái)調(diào)...
    hjw2015閱讀 1,256評(píng)論 0 1
  • Services services 是每個(gè)Feathers 應(yīng)用的核心去扣。他們執(zhí)行應(yīng)用級(jí)別的I/O操作柱衔,實(shí)現(xiàn)數(shù)據(jù)進(jìn)出...
    hjw2015閱讀 1,080評(píng)論 0 2
  • 自己最近的項(xiàng)目是基于react的,于是讀了一遍react的文檔愉棱,做了一些記錄(除了REFERENCE部分還沒(méi)開(kāi)始讀...
    潘逸飛閱讀 3,360評(píng)論 1 10
  • 數(shù)組是一個(gè)有序數(shù)列唆铐,相同的元素也可以重復(fù)的出現(xiàn)在同一個(gè)數(shù)組中。數(shù)組羽氮,集合和字典中都只能存放明確類(lèi)型的 值 或者 鍵...
    Counting_S閱讀 468評(píng)論 3 1