下面是View显示代码:
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
$(function () {
var editRow = undefined;
$("#tb1").datagrid({
fitColumns: true,
striped: true,
//这里需要接收【总行数total】和【数据组rows】的【JSON格式】的数据{total:23,rows:[{},{}]}
url: "/UserExpression/GetAllUserInfos",
singleSelect: false,
pagination: true,
rownumbers: true,
pageSize: ,
pageList: [, , ],
columns: [
[// u.Id,u.UName,u.Pwd,u.Remark,u.SubTime
{ title: "用户名", field: "UName", allgn: "center", width: },
{ title: "密码", field: "Pwd", allgn: "center", width: },
{ title: "备注", field: "Remark", allgn: "center", width: },
{ title: "保存时间", field: "SubTime", allgn: "center", width: },
{
title: "编辑", field: "xx", allgn: "center", width: , formatter: function (value, row, index) {
return btn;
}
},
]
],
//在数据加载成功的时候触发。
onLoadSuccess: function (data) {
$('.Update').linkbutton({
text: '修改',
iconCls: 'icon-edit',
plain: true,//是否显示边线
onClick: function () {
var zhi = $("#tb1").datagrid("getSelections");
window.location.href = '/HomeText/Edit?id=' + zhi[].productID;
}
})
$('.delete').linkbutton({
text: '删除',
iconCls: 'icon-edit',
plain: true,//是否显示边线
onClick: function () {
var zhi = $("#tb1").datagrid("getSelections");
$.ajax({
type: 'POST',
dataType: 'json',
url: '/HomeText/DeleteConfirmed?id=' + zhi[].productID,
success: function (data) {
$("#tb1").datagrid("reload");
}
})
}
})
},
toolbar: [
{
text: "添加",
iconCls: "icon-add",
handler: function () {
window.open("/HomeText/Create")
}
},
{
text: "删除",
iconCls: "icon-cancel",
}
],
})
})
下面是Controller后台代码:
using IBLL;
using SQLModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MVC展示数据.Controllers
{
public class UserExpressionController : Controller
{
//利用spring.net在Config里面进行配置,这样就不用new对象了
public IUserInfo UserInfoBLL2 { get; set; }
#region 加载用户的数据
public ActionResult Index()
{
return View();
}
public ActionResult GetAllUserInfos()
{
//根据分页显示数据
int pageSize = Request["rows"] == null ? : int.Parse(Request["rows"]);
int pageIndex = Request["page"] == null ? : int.Parse(Request["page"]);
//--------------------------------第几页,每页几条,根据id进行查询
var data = UserInfoBLL2.LoadByPage(pageIndex, pageSize, n => n.Id)
//-----避免重复查询
.Select(u => new { u.Id, u.UName, u.Pwd, u.Remark, u.SubTime });
//总的数据条数
int total = UserInfoBLL2.Load().Count();
var result = new { total=total,rows=data};
return Json(result, JsonRequestBehavior.AllowGet);
}
#endregion
}
}
部分视图展示:
easyUI + servlet 展示datagrid数据列表
1:在jsp页面添加所用easyUI的js和css 2.前台代码示例:
【开源】OSharp框架解说系列(2.2):EasyUI复杂布局及数据操作
OSharp是什么? OSharp是个快速开发框架,但不是一个大而全的包罗万象的框架,严格的说,OSharp中什么都没有实现.与其他大而全的框架最大的不同点,就是OSharp只做抽象封装,不做实现.依 ...
随机推荐
WIN7下java环境的搭建
首先,你应该已经安装了 java 的 JDK 了,笔者安装的是:jdk-7u7-windows-x64 接下来主要讲怎么配置 java 的环境变量,也是为了以后哪天自己忘记了做个备份 1.进入“计算机 ...
Codeforces Round #337 (Div. 2) C. Harmony Analysis 构造
C. Harmony Analysis 题目连接: http://www.codeforces.com/contest/610/problem/C Description The semester i ...
java学习笔记 (9) —— Struts2 国际化
1.Test.java package com.i18n; import java.util.Locale; public class Test1 { public static void main( ...
Ubuntu14.04配置arm-linux-gcc 4.4.3交叉编译环境
首先下载交叉编译:不多说,直接贴地址了 http://arm9download.cncncn.com/mini2440/linux/arm-linux-gcc-4.4.3-20100728.tar.g ...
poj 3311 Hie with the Pie(状态压缩dp)
Description The Pizazz Pizzeria prides itself or more (up to ) orders to be processed before he star ...
matlab和C语言的break及continue测试
break和continue语句 有两个附加语句可以控制while和for循环:break和continue语句.break语句可以中止循环的执行和跳到end后面的第一句执行,而continue只中止 ...
Windows下caffe的python接口配置
主要是因为,发现很多代码是用python编写的,在这里使用的python安装包是anaconda2. 对应下载地址为: https://www.continuum.io/downloads/ 安装py ...
io使用的设计模式
File f = new File("c:/a.txt"); 1. FileInputStream fis = new FileInputStream(f); 2. Reader ...
pygme 安装
输入pip install pygame-1.9.3-cp36-cp36m-win32.whl ModuleNotFoundError: No module named 'requests' pip ...