国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

使用jquery datatable和bootsrap創(chuàng)建表格實例代碼

2019-11-19 17:07:46
字體:
供稿:網(wǎng)友

 使用jquery-datatable插件

bootstrap前端框架

json

一.創(chuàng)建demo.html

代碼塊

代碼塊語法遵循標準markdown代碼,例如:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%><%  String path = request.getContextPath();  String basePath = request.getScheme() + "://"      + request.getServerName() + ":" + request.getServerPort()      + path + "/";%><!DOCTYPE html><html lang="en" class="app"><head><meta charset="utf-8" /><title>XXX服務(wù)平臺</title><meta name="description"  content="app, web app, responsive, admin dashboard, admin, flat, flat ui, ui kit, off screen nav" /><meta name="viewport"  content="width=device-width, initial-scale=1, maximum-scale=1" /><link rel="stylesheet"  href="<%=request.getContextPath()%>/www/AL_app/js/jPlayer/jplayer.flat.css" rel="external nofollow"   type="text/css" /><link rel="stylesheet"  href="<%=request.getContextPath()%>/www/AL_app/css/bootstrap.css" rel="external nofollow"   type="text/css" /><link rel="stylesheet"  href="<%=request.getContextPath()%>/www/AL_app/css/font.css" rel="external nofollow"   type="text/css" /><link rel="stylesheet"  href="<%=request.getContextPath()%>/www/AL_app/css/app.css" rel="external nofollow"   type="text/css" /><link rel="stylesheet" href="<%=request.getContextPath()%>/www/AL_app/js/datatables/datatables.css" rel="external nofollow" type="text/css"/><!--[if lt IE 9]>  <script src="js/ie/html5shiv.js"></script>  <script src="js/ie/respond.min.js"></script>  <script src="js/ie/excanvas.js"></script> <![endif]--></head><body class=""<!-- ***********醫(yī)用藥典開始************** --><section id="content">     <section class="vbox">      <section class="scrollable padder">      <div class="m-b-md">        <h3 class="m-b-none"></h3>       </div>       <div class="m-b-md">        <h3 class="m-b-none">中醫(yī)藥典</h3>       </div>       <section class="panel panel-default">        <header class="panel-heading">         清單         <i class="fa fa-info-sign text-muted" data-toggle="tooltip" data-placement="bottom" data-title="ajax to load the data."></i>         </header>        <div class="table-responsive">         <table class="table table-striped m-b-none" data-ride="datatables">           <thead>           <tr>            <th style="width:15%" >序號</th>            <th style="width:20%">藥名</th>            <th style="width:20%">拼音簡稱</th>            <th style="width:15%">用法</th>                             <th style="width:15%">操作</th>           </tr>                 </thead>          <tbody>          </tbody>         </table>        </div>       </section>      </section>     </section>     <a href="#" rel="external nofollow" class="hide nav-off-screen-block" data-toggle="class:nav-off-screen,open" data-target="#nav,html"></a>    </section>    <!-- ***********醫(yī)用藥典結(jié)束************** -->      </section>    </section>  </section><script src="<%=request.getContextPath()%>/www/AL_app/js/jquery.min.js"></script>  <!-- Bootstrap --><script src="<%=request.getContextPath()%>/www/AL_app/js/bootstrap.js"></script>  <!-- App --><script src="<%=request.getContextPath()%>/www/AL_app/js/app.js"></script><script type="text/javascript"    src="<%=request.getContextPath()%>/www/AL_app/js/jPlayer/demo.js"></script><script src="<%=request.getContextPath()%>/www/AL_app/jh_js/jq.dataTable.js"></script><script src="<%=request.getContextPath()%>/www/AL_app/js/datatables/jquery.csv-0.71.min.js"></script><script src="<%=request.getContextPath()%>/www/AL_app/drugs/demo.js"></script><script src="<%=request.getContextPath()%>/www/AL_app/js/app.plugin.js"></script></body></html>

二.創(chuàng)建一個drugs.json

{  "aaData": [  {    "序號": "1",    "藥名": "白術(shù)",    "拼音簡稱": "bzh",    "用法": "內(nèi)服",    "操作": "編輯"  },   {    "序號": "3",    "藥名": "白術(shù)",    "拼音簡稱": "bzh",    "用法": "內(nèi)服",    "操作": "編輯"  },   {    "序號": "4",    "藥名": "白術(shù)",    "拼音簡稱": "bzh",    "用法": "內(nèi)服",    "操作": "編輯"  },   {    "序號": "5",    "藥名": "白術(shù)",    "拼音簡稱": "bzh",    "用法": "內(nèi)服",    "操作": "編輯"  },   {    "序號": "6",    "藥名": "白術(shù)",    "拼音簡稱": "bzh",    "用法": "內(nèi)服",    "操作": "編輯"  }]

三.創(chuàng)建一個demo.js

/** 使用jquery-datatable異步請求數(shù)據(jù)創(chuàng)建表格 **/+function ($) { "use strict"; $(function(){ // datatable $('[data-ride="datatables"]').each(function() {  var oTable = $(this).dataTable( {   "bProcessing": true,   "sAjaxSource": "www/AL_app/drugs/drugs.json",//異步請求json數(shù)據(jù)   "sDom": "<'row'<'col-sm-6'l><'col-sm-6'f>r>t<'row'<'col-sm-6'i><'col-sm-6'p>>",   "sPaginationType": "full",   //給表格單元的頭信息命名   "aoColumns": [    { "mData": "序號" },    { "mData": "藥名" },    { "mData": "拼音簡稱" },    { "mData": "用法" },    { "mData": "操作" }   ]  } ); });}(window.jQuery);

四.截圖如下所示

這張圖片有點丑
這張效果好一些

以上所述是小編給大家介紹的使用jquery datatable和bootsrap創(chuàng)建表格實例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對武林網(wǎng)網(wǎng)站的支持!

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 永嘉县| 石家庄市| 营口市| 襄汾县| 平远县| 南木林县| 水富县| 丰县| 驻马店市| 北海市| 阳春市| 富民县| 广平县| 肃宁县| 崇礼县| 米林县| 万盛区| 广饶县| 长治市| 碌曲县| 河池市| 临海市| 绥江县| 当阳市| 辉南县| 徐闻县| 揭西县| 甘泉县| 乌审旗| 阿城市| 太和县| 鲁山县| 安图县| 河北区| 军事| 临颍县| 万山特区| 汉沽区| 论坛| 信丰县| 通城县|