惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
爱范儿
爱范儿
T
The Exploit Database - CXSecurity.com
量子位
T
Tailwind CSS Blog
T
Threatpost
The GitHub Blog
The GitHub Blog
AWS News Blog
AWS News Blog
云风的 BLOG
云风的 BLOG
K
Kaspersky official blog
P
Proofpoint News Feed
博客园 - 司徒正美
L
LangChain Blog
T
Threat Research - Cisco Blogs
C
CERT Recently Published Vulnerability Notes
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
S
Secure Thoughts
The Last Watchdog
The Last Watchdog
Spread Privacy
Spread Privacy
H
Hacker News: Front Page
T
Troy Hunt's Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
W
WeLiveSecurity
A
Arctic Wolf
Apple Machine Learning Research
Apple Machine Learning Research
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
P
Proofpoint News Feed
T
Tor Project blog
T
The Blog of Author Tim Ferriss
I
Intezer
P
Privacy & Cybersecurity Law Blog
美团技术团队
N
Netflix TechBlog - Medium
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Vulnerabilities – Threatpost
Application and Cybersecurity Blog
Application and Cybersecurity Blog
G
Google Developers Blog
Attack and Defense Labs
Attack and Defense Labs
T
Tenable Blog
月光博客
月光博客
Stack Overflow Blog
Stack Overflow Blog
J
Java Code Geeks
腾讯CDC
Microsoft Security Blog
Microsoft Security Blog
A
About on SuperTechFans
Last Week in AI
Last Week in AI

博客园 - meetweb

IDEA 使用generator逆向工程生成pojo,mapper Ambiguous reference to member 'dataTask(with:completionHandle:)'错误 swift3.0  代码创建经典界面的九宫图--优化篇 swift3.0 创建经典界面的九宫图 AlertDialog中使用ListView绑定数据 bootstrap table教程--使用入门基本用法 jqGrid使用json实现的范例一 android logger的使用 通过反射获取DLL的类实现加载窗体 Visual 2015创建新项,缺少ADO.NET 实体数据模型的解决方法 在VisualStadio2015上使用EF6.0建立MySql数据库 事件使用(转 ) 使用Dotfuscator 进行.Net代码混淆 代码加密的方法 Git分布式版本控制系统学习笔记 免费SVN服务器笔记 如何设置mysql远程访问及防火墙设置 c# GridControl怎么换行 模拟Post登陆带验证码的网站 c#控制打印机杂项
bootstrap table教程--后台数据绑定、特殊列处理、排序
meetweb · 2017-05-26 · via 博客园 - meetweb

上一篇文章介绍了基本的使用教程。本节主要介绍Bootstrap的后台数据绑定、特殊列处理及列的排序功能

1.数据绑定

 一般做程序设计,很少是使用json文件直接绑定数据。基本上我们都是使用编程语言进行数据获取,并做数据绑定。

放置一个Table控件

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

调用javascript的代码

<script >
$('#table').bootstrapTable({
    url: 'tablejson.jsp',   //数据绑定,后台的数据从jsp代码
    search:true,            
    uniqueId:"Id",
    pageSize:"5",
    pageNumber:"1",
    sidePagination:"client",
    pagination:true,
    height:'400',
    columns: [
    
    {
        field: 'Id',
        title: '中文'
    }, {
        field: 'Name',
        title: 'Name'
    }
    , {
        field: 'Desc',
        title: 'Desc'
    }
    
    ],
    
});

2.特殊列处理

 在实际应用中,我们需要增加我们的特殊列,例如是操作列,看下列的js代码 增加了一个特殊列

{
       field: '#',
        title: 'control',formatter:function(value,row,index){
        var del='<a href="Delete!delete.action?Id='+row.Id+'">删除</a>';
        var updt='<a href="supdate.jsp?Id='+row.Id+'">修改</a>';
        var add='<a href="Include.jsp?Id='+row.Id+'">增加</a>'
        return del+" "+updt+"&nbsp"+add;
        }
    }   

js的代码修改为

<script >
$('#table').bootstrapTable({
    url: 'tablejson.jsp',   //数据绑定,后台的数据从jsp代码
    search:true,            
    uniqueId:"Id",
    pageSize:"5",
    pageNumber:"1",
    sidePagination:"client",
    pagination:true,
    height:'400',
    columns: [
    
    {
        field: 'Id',
        title: '中文'
    }, {
        field: 'Name',
        title: 'Name'
    }
    , {
        field: 'Desc',
        title: 'Desc'
    }
,
{
       field: '#',
        title: 'control',formatter:function(value,row,index){
        var del='<a href="Delete!delete.action?Id='+row.Id+'">删除</a>';
        var updt='<a href="supdate.jsp?Id='+row.Id+'">修改</a>';
        var add='<a href="Include.jsp?Id='+row.Id+'">增加</a>'
        return del+" "+updt+"&nbsp"+add;
        }
    }
], });

3.列的排序,排序主要是在列中增加了一个属性 

{
        field: 'Name',
        title: 'Name',sortable:true
    }