一、前言

       新年新气象,转眼今年就28了,不知道今年能不能把妹成功呢?哈哈哈!上班第一天,部门Web技术主管给每个同事都发了红包鼓励大家今年加油,我作为新转入部门员工不能给团队掉链子,要加紧学习跟上队伍。大家都下班了,我安安静静总结之前BootStrap的知识内容。

二、内容

<div>
<table id="ExampleTable" data-toggle="table" class="table table-hover"
data-url="/api/Controller/Action"
data-method="post" //Post方式获取数据
data-side-pagination="server" //服务器分页
data-pagination="true" //是否支持分页
data-query-params-type="" //如果支持RestFul需要写'limit'
data-query-params = qcondition> //查询条件
<thead>
<tr>
<th data-field="field1" data-valign="middle">字段1</th>
<th data-field="field2" data-valign="middle" data-class="field2-class" data-formatter="Formatfield2" data-events="operateField2Events">字段2</th>
<th data-formatter="FormatItem3" data-valign="middle">项目3</th>
</tr>
</thead>
</table>
</div>

BootStrap的<table>标签:

主要说明的是data-query-params这个属性,它是用来对获取到的服务器数据进行筛选的,我们可以在js中这么写:

var qcondition = function (params) {
var temp = {
        FilterText: filterValue,
        Condition: params.searchText,
        PageSize: params.pageSize,
        PageIndex: params.pageNumber - 1
    };
    return temp;
};

那么在Controller中,我们就需要根据qcondition获取相应的数据:


public class QueryDataInfo
{  
    public string FilterText { get; set; }
    public string Condition { get; set; }
    public int PageIndex { get; set; }
    public int PageSize { get; set; }
}
[HttpPost]
public HttpResponseMessage Action(QueryDataInfo dataInfo)
{
long recordCount = ;
IList<DataInfo> list = Query(dataInfo, out recordCount);
return ResultJson.BuildJsonResponse(new { total = recordCount, rows = list }, MessageType.None, string.Empty);
} public IList<DataInfo> Query(QueryDataInfo dataInfo, out long recordCount)
{
     IList<DataInfo> list = new List<DataInfo>();
     string[] includePath = {"ForeignKey"};   
list = DataRepository.LoadPageList(out recordCount,
dataInfo.PageIndex * dataInfo.PageSize,
dataInfo.PageSize,
            d => d.Text == dataInfo.FilterText,
            o => o.ID,
false,
includePath);   
    return list;
} //以下代码写在基抽象类中
public IList<TEntity> LoadPageList<TKey>(out long count,
int pageIndex,
int pageSize,
Expression<Func<TEntity, bool>> expression = null,
Expression<Func<TEntity, TKey>> orderBy = null,
bool ascending = true,
params string[] includePath)
{
     IQueryable<TEntity> defaultQuery = Query(expression,
includePath);
     if (orderBy != null)
     {
        if (ascending)
            defaultQuery = defaultQuery.OrderBy(orderBy);
        else
            defaultQuery = defaultQuery.OrderByDescending(orderBy);
     }
     count = defaultQuery.Count();
     defaultQuery = defaultQuery.Skip(pageIndex).Take(pageSize);
     return defaultQuery.ToList();
} public IQueryable<TEntity> Query(Expression<Func<TEntity, bool>> expression = null,
params string[] includePath)
{
     IQueryable<TEntity> defaultQuery = mobjContext.Context.Set<TEntity>();
     if (includePath != null)
     {
        foreach (string path in includePath)
        {
             if (!string.IsNullOrEmpty(path))
             {
                  defaultQuery = defaultQuery.Include(path);
             }
         }
     }      if (expression != null)
         defaultQuery = defaultQuery.Where(expression);
     return defaultQuery;
}

BootStrap的<th>标签:

data-field: 数据字段,对应返回的对象中的字段。

data-class: 该<th>标签的class,一般用于该列的自定义css样式

<style>
.field2-class {
min-height: 0px;
}
</style>

data-formatter: 对该列数据进行格式上的变化

function Formatfield2(value, row, index) {
return '<span class="link-name item-name">' + row.Name + '</span><input type="hidden" class="hiddenRowid" value='+row.ID+' />';
}

data-events:  该列数据事件,如点击该列的某个字段会发生何种事件

window.operateField2Events = {
'click .class-name': function (e, value, row, index) {
//do something
}
}

官方文档:

http://bootstrap-table.wenzhixin.net.cn/zh-cn/documentation/

三、结尾

       以后会持续更新关于BootStrap的相关内容!

【BootStrap】Table的基本使用的更多相关文章

  1. BootStrap table使用

    bootstrap table git address https://github.com/wenzhixin/bootstrap-table 引入文件 <link rel="sty ...

  2. bootstrap Table 中给某一特定值设置table选中

    bootstrap Table 中给某一特定值设置table选中 需求: 如图所示:左边地图人员选定,右边表格相应选中. 功能代码: //表格和图标联动 function changeTableSel ...

  3. JS组件系列——表格组件神器:bootstrap table

    前言:之前一直在忙着各种什么效果,殊不知最基础的Bootstrap Table用法都没有涉及,罪过,罪过.今天补起来吧.上午博主由零开始自己从头到尾使用了一遍Bootstrap Table ,遇到不少 ...

  4. JS组件系列——表格组件神器:bootstrap table(二:父子表和行列调序)

    前言:上篇 JS组件系列——表格组件神器:bootstrap table 简单介绍了下Bootstrap Table的基础用法,没想到讨论还挺热烈的.有园友在评论中提到了父子表的用法,今天就结合Boo ...

  5. JS组件系列——表格组件神器:bootstrap table(三:终结篇,最后的干货福利)

    前言:前面介绍了两篇关于bootstrap table的基础用法,这章我们继续来看看它比较常用的一些功能,来个终结篇吧,毛爷爷告诉我们做事要有始有终~~bootstrap table这东西要想所有功能 ...

  6. JS组件系列——Bootstrap Table 冻结列功能IE浏览器兼容性问题解决方案

    前言:最近项目里面需要用到表格的冻结列功能,所谓“冻结列”,就是某些情况下表格的列比较多,需要固定前面的几列,后面的列滚动.遗憾的是,bootstrap table里自带的fixed column功能 ...

  7. JS组件系列——Bootstrap Table 表格行拖拽

    前言:之前一直在研究DDD相关知识,好久没更新JS系列文章了.这两天做了一个简单的业务需求,觉得效果还可以,今天在这里分享给大家,欢迎拍砖~~ 一.业务需求及实现效果 项目涉及到订单模块,那天突然接到 ...

  8. JS组件系列——Bootstrap Table 表格行拖拽(二:多行拖拽)

    前言:前天刚写了篇JS组件系列——Bootstrap Table 表格行拖拽,今天接到新的需要,需要在之前表格行拖拽的基础上能够同时拖拽选中的多行.博主用了半天时间研究了下,效果是出来了,但是感觉不尽 ...

  9. 后台系统组件:一丶bootstrap table

    http://www.cnblogs.com/landeanfen/p/4976838.html (bootstrap table) http://www.cnblogs.com/landeanfen ...

  10. Bootstrap Table Examples

    The examples of bootstrap table http://bootstrap-table.wenzhixin.net.cn/examples/ http://www.jq22.co ...

随机推荐

  1. react-native初体验(1) — hello world

    没有简介,直接开始干活吧. 默认阅读本文的你已经安装好 nodejs, windows用户需要升级yarn到最新版本. 并且设置安装源为国内的淘宝源: npm config set registry ...

  2. Linux速成(一)

    全部转载自http://www.runoob.com/linux/linux-intro.html 一.Linux 简介 Linux是一套免费使用和自由传播的类Unix操作系统,是一个基于POSIX和 ...

  3. python装饰器(披着羊皮的狼)

    python装饰器的作用是在不改变原有函数的基础上,对函数的功能进行增加或者修改. 装饰器语法是python语言更加优美且避免很多繁琐的事情,flask中配置路由的方式便是装饰器. 首先python中 ...

  4. (1) Python 数据类型功能

    1.int 将字符串转化为数字 a="123"  print(type(a),a) b=int(a)  print(type(b),b) num="0011" ...

  5. 火狐插件安装-基于web自动化测试

    一.Firebug 安装 1.  打开火狐浏览器—选择右上角“打开菜单”(图一)----附件组件(图二) 图一 图二 2.  点击:扩展(图三)—-------用于所有附加组件的工具(图四)----选 ...

  6. 从零系列--node爬虫利用进程池写数据

    1.主进程 const http = require('http'); const fs = require('fs'); const cheerio = require('cheerio'); co ...

  7. php学习--变量和数据类型

    PHP变量 变量 ​ 程序执行期间,可以变化的量即为变量. 声明变量 以美元$ 符号声明 注意:(PHP严格区分大小写) 变量名称以 字母.或下划线开始,后面跟上数字/字母/下划线,不能包含特殊字符 ...

  8. ltrace命令详解

    原文链接:https://ipcmen.com/ltrace 用来跟踪进程调用库函数的情况 补充说明 NAME       ltrace - A library call tracer ltrace命 ...

  9. Daily Scrumming* 2015.10.26(Day 7)

    一.总体情况总结 今天我们开会具体讨论了一下接下来的任务.还详细讨论了一下分数的分配,具体分数分配我们会在下一篇博客中详细说明. 我们下一周大致的工作安排如下: 1.UI:完成社团后台界面的设计,以及 ...

  10. 第二阶段每日站立会议Second Day

    昨天我在手机端安装cpp后进行界面效果测试以及进一步完善 今天对图片显示的大小进行调整 遇到的问题:当图片太小时,显示一块灰色区域,不美观