MVC bootstrap-table显示数据时显示No matching records found
问题:bootstrap-table加载数据不显示
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<script>
$(function () {
InitMainTable();
document.onkeydown = function (e) {
var ev = document.all ? window.event : e;
if (ev.keyCode == 13) {// 如(ev.ctrlKey && ev.keyCode==13)为ctrl+Center 触发
$("#table").bootstrapTable('refresh');
}
}
$("#rearch").click(function () {
$("#table").bootstrapTable('refresh');
});
});
function InitMainTable() {
//先销毁表格
$("#table").bootstrapTable('destroy');
$("#table").bootstrapTable({
method: "get"
, url: "/Type/DataList"
, striped: true, //表格显示条纹
pagination: true,// 是否显示分页
pageSize: 10, //每页显示条数
pageNumber: 1,//当前第几页
search: true, //显示搜索框
buttonsAlign: "right", //按钮对齐方式
pageList: [5, 10, 15, 20, 25],
showColumns: true,
showRefresh: true, //是否显示刷新按钮
sidePagination: "server", //表示从服务端获取数据
queryParamsType: "undefined", //定义参数类型
queryParams: function (params) {
//console.log(params);
var param = {
keyword: $("#search").val(),//搜索
pageIndex: params.pageNumber,
pageSize: params.pageSize
};
return param;
},
columns: [{
field: "TypeName"
, title: "名称"
, sortable: true
}, {
field: "Typevalue"
, title: "类型值"
, sortable: true
}, {
field: "FullPath"
, title: "表名"
, sortable: true
}, {
field: "StateName"
, title: "是否显示"
, sortable: true
, formatter: function (value, row, index) {
var isdisplay = row["StateName"];
if (isdisplay == "6f9619ff-8b86-d011-b42d-34c04fc964ff") {
isdisplay = ' <span class="label label-lg label-yellow arrowed-in">是</span>';
} else {
isdisplay = '<span class="label label-lg label-purple arrowed">否</span>';
}
return isdisplay;
}
}, {
title: '操作',
align: 'center',
width: 230,
formatter: function (value, row, index) {
var icon = '<button class="btn btn-xs btn-primary" onclick="Update(\'' + row.TyId + '\')"><i class="icon-edit bigger-120">编辑</i></button> '
icon += '<button class="btn btn-xs btn-danger" onclick="Del(\'' + row.TyId + '\')"><i class="icon-trash bigger-120">删除</i></button>';
return icon;
}
}],
onLoadSuccess: function (data) {
console.log(data);
},
onLoadError: function () {
alert("数据加载失败!");
}
});
}
//删除
function Del(tyid) {
if (confirm("你确定要删除吗?")) {
$.post("/Type/Reovme", { tyid: tyid }, function (data) {
if (data.code == 200) {
window.location.reload();
} else {
layer.msg(data.msg, { icon: 5 });
}
});
}
}
function Update(typeid) {
window.location.href = "/Type/AddUpdate?typeId="+typeid;
}
function Add() {
window.location.href = "/Type/AddUpdate";
}
</script>
<div class="input-group col-md-3" style="margin-top:0px">
<input type="text" class="form-control"placeholder="请输入字段名" id="search" / >
<span class="input-group-btn">
<button class="btn btn-sm btn-search" id="rearch">
<i class="icon-search bigger-110"></i>
<span class="bigger-110 no-text-shadow">查找</span>
</button>
<button class="btn btn-sm btn-success" onclick="Add()"><i class="icon-pencil bigger-110">添加</i></button>
</span>
</div>
<table class="table table-hover table-striped" border="0" id="table" style="border-width: 0px; border-collapse: collapse;">
</table>
代码是没有问题的但是就是一直不显示,加载的时候是有数据输出,当时找了好久。一直都找不出来,后来发现控制器返回json格式有问题。
//控制器
/// <summary>
/// 查询角色表
/// </summary>
/// <returns></returns>
public ActionResult getRoleAll(int pageIndex, int pageSize)
{
ISys_RoleBLL irb = new Sys_RoleBLL();
List<Sys_Role> list = irb.getRoleAll();
var data = (from role in list
select new
{
role.RoId,
role.EnCode,
role.FullName,
DeleteMark=Convert.ToInt32(role.DeleteMark).ToString()=="1"?"可用":"不可用",
}).Skip((pageIndex-1)*pageSize).Take(pageSize);
var resut = new { rows = data }; 当时没有加上这句话,直接返回data数据,导致页面有数据输出,table表格无数据。这里需要返回匿名类型的数据
return Json(resut, JsonRequestBehavior.AllowGet);
}
MVC bootstrap-table显示数据时显示No matching records found的更多相关文章
- Spring MVC中传递json数据时显示415错误解决方法
在ajax中设置 ContentType为'application/json;charset=utf-8' 传递的data类型必须是json字符串类型:{“key”:"value" ...
- 实现easyui datagrid在没有数据时显示相关提示内容
本示例实现easyui datagrid加载/查询数据时,如果没有相关记录,则在datagrid中显示没有相关记录的提示信息,效果如下图所示 本实例要实现如下图所示的效果: 本示例easyui版本为1 ...
- [转] BootStrap table增加一列显示序号
原文地址:https://blog.csdn.net/aboboo5200/article/details/78839208 最近由于项目需要,使用BootStrap table做数据展示,其中要在第 ...
- easy ui datagrid在没有数据时显示相关提示内容
$(function () { $('#dg').datagrid({ fitColumns: true, url: 'product.json', pagination: true, pageSiz ...
- easyui datagrid 没数据时显示滚动条的解决方法
今天解决了一个bug,因为datagrid有多列,可是当没有数据的时候,后面的列无法通过滚动条拉动来显示,比较麻烦,而需求要求没有数据也要拉动滚动条查看后面有什么列,一开始在网上找了一些资料,发现都不 ...
- 扩展:gridview 空数据时显示表头
2015年7月14日16:50:06 Gridview 默认展示数据时,若数据为空,则表格不显示,显示不美观. 针对此问题进行扩展: using System.Web.UI.WebControls; ...
- laravel post提交数据时显示异常
post提交数据时候显示如下: The page has expired due to inactivity. Please refresh and try again 这是由于在laravel框架中 ...
- bootstrap Table动态绑定数据并自定义字段显示值
第一步:我们在官网下载了bootstrap 的文档,并在项目中引入bootstrap table相关js文件,当然,也要记得引入jquery文件 大概如图: 第二步:定义一个table控件 第三步:j ...
- .Net MVC+bootstrap Table学习
一.效果展示 二.使用方法 1).相关css和js的引用 <link href="~/Themes/Bootstrap/css/bootstrap.css" rel=&quo ...
随机推荐
- ssh框架整合笔记
1.建立普通的Javaweb项目,导入项目所必须的jar包. 2.配置web.xml文件. web.xml 3.在src下建立struts.xml. struts.xm 4.在实体包下配置 实体名 ...
- 链表底层实现Java的Map(上)
链表实现Map public class LinkListMap<K,V> implements Map<K,V> { private class Node { public ...
- Python中pathlib模块
Python中pathlib模块 Path.cwd():返回当前目录的路径 Path.home():返回当前用户的家目录 Path.stat():返回此路径信息 Path.touch():创建文件 P ...
- 【Android Studio安装部署系列】目录
概述 从刚开始使用Android Studio到现在,下面所有目录下的操作,当时习惯性的把每一个整理成一个文档(其实就是简单文字描述+截图):有些地方当时是一知半解,现在会稍微明白一些.正好赶上现在有 ...
- css中margin为负数的深入研究
注:以下实验的元素均为块级元素,inline-block和inline本身对margin某些方向上都是无效的,所以这里不予讨论. margin-left或者margin-right为负数 当块元素wi ...
- Protocol Buffers(1):序列化、编译与使用
目录 序列化与反序列化 Protocol Buffers概览 Protocol Buffers C++ 编译 Protocol Buffers C++ 使用 Protocol Buffers的可读性 ...
- 讲解:为什么重写equals时必须重写hashCode方法
一 :string类型的==和equals的区别: 结论:"=="是判断两个字符串的内存地址是否相等,equals是比较两个字符串的值是否相等,具体就不做扩展了,有兴趣的同学可以去 ...
- 邀您参加 | BigData & Alluxio 交流会-成都站
4月27日,在天府之国,与你共享大数据与Alluxio的技术魅力. 活动介绍 本期技术沙龙将会聚焦在大数据.存储.数据库以及Alluxio应用实践等领域,邀请腾讯技术专家和业界技术专家现场分享关于Al ...
- SLAM+语音机器人DIY系列:(六)SLAM建图与自主避障导航——2.google-cartographer机器人SLAM建图
摘要 通过前面的基础学习,本章进入最为激动的机器人自主导航的学习.在前面的学习铺垫后,终于迎来了最大乐趣的时刻,就是赋予我们的miiboo机器人能自由行走的生命.本章将围绕机器人SLAM建图.导航避障 ...
- Spring Boot入门(三):使用Scheduled注解实现定时任务
在程序开发的过程中,经常会使用定时任务来实现一些功能,比如: 系统依赖于外部系统的非核心数据,可以定时同步 系统内部一些非核心数据的统计计算,可以定时计算 系统内部的一些接口,需要间隔几分钟或者几秒执 ...