全自动数据表格JQuery版



@{
ViewBag.Title = "Table";
Layout = "~/Areas/Admin/Views/Shared/_GridLayout.cshtml";
}
@section customScript{
<script type="text/javascript">
var enums = @Html.Raw(Json.Encode(@ViewBag.Enums));
url = {
read: "/api/services/product/products/GetProductPagedList",
add: "/api/services/product/products/CreateProduct",
edit: "/api/services/product/products/UpdateProduct",
delete: "/api/services/product/products/DeleteProduct"
};
columns = [
{ data: "id", title: "编号" },
{ data: "name", title: "商品名称", type: "text", query: true, editor: {} },
{ data: "brief", title: "商品简介", type: "textarea", query: true, editor: {} },
//{ data: "detail", title: "商品详情", type: "richtext", query: true, editor: {} },
{ data: "price", title: "价格", type: "number", query: true, editor: {} },
{ data: "cover2", title: "封面", type: "img", editor: {} },
{ data: "isOnShelf", title: "是否上架", type: "switch", editor: {} },
{ data: "enumTest", title: "枚举测试", type: "dropdown", editor: {},source:{data:enums} },
{ data: "onShelfTime", title: "上架时间", type: "timepicker", editor: {} },
{
title: "操作选项",
type: "command",
actions: [
{
name: "操作",
icon: "fa-trash-o",
onClick: function (d) {
alert(d["id"]);
}
}
]
}
];
</script>
}
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Threading.Tasks;
using Abp.Application.Services;
using Abp.Application.Services.Dto;
using Abp.Application.Services.Query;
using Abp.AutoMapper;
using Abp.Domain.Repositories;
using BodeAbp.Product.Products.Dtos; namespace BodeAbp.Product.Products
{
/// <summary>
/// 商品 应用服务
/// </summary>
public class ProductsAppService : ApplicationService, IProductsAppService
{
private readonly IRepository<Domain.Product,long> _productRepository; /// <summary>
/// 构造函数
/// </summary>
/// <param name="productRepository"></param>
public ProductsAppService(IRepository<Domain.Product, long> productRepository)
{
_productRepository = productRepository;
} /// <inheritdoc/>
public async Task<PagedResultOutput<GetProductListOutput>> GetProductPagedList(QueryListPagedRequestInput input)
{
int total;
var list = await _productRepository.GetAll().Where(input, out total).ToListAsync();
return new PagedResultOutput<GetProductListOutput>(total, list.MapTo<List<GetProductListOutput>>());
} /// <inheritdoc/>
public async Task CreateProduct(CreateProductInput input)
{
var product = input.MapTo<Domain.Product>();
await _productRepository.InsertAsync(product);
} /// <inheritdoc/>
public async Task UpdateProduct(UpdateProductInput input)
{
var product = await _productRepository.GetAsync(input.Id);
input.MapTo(product);
await _productRepository.UpdateAsync(product);
} /// <inheritdoc/>
public async Task DeleteProduct(IdInput input)
{
await _productRepository.DeleteAsync(input.Id);
}
}
}
{
"pageIndex":,
"pageSize":,
"sortConditions":[
{
"sortField":"name",
"listSortDirection":
}
],
"filterGroup":{
"rules":[
{
"field":"displayName",
"operate":"contains",
"value":"a"
}
]
}
}
服务端响应Json格式:
{
"success": true,
"result": {
"totalCount": ,
"items": [
{
"name": "名称222",
"brief": "简介222",
"detail": "<p>描述222</p>",
"price": 3.33,
"cover2": "xx",
"isOnShelf": true,
"onShelfTime": "1899-12-03T03:00:00+08:00",
"enumTest": ,
"id":
}
]
},
"error": null,
"unAuthorizedRequest": false
}
items中的字段应与视图页中列配置一一对应,这样很少的代码就能完全实现数据的展示、分页、新增、编辑、删除、查询、排序等功能,并且还统一了编码方式,方便质量把控和后期维护。数据表格核心文件:bode.grid.js。在BodeAbp项目中可以看到源码以及一个比较完善的demo。整个demo依然遵循前后端分离的模式,只用到了MVC的视图页作为前端展示。BodeAbp项目地址:https://github.com/liuxx001/BodeAbp。
| 参数 | 类型 | 说明 | 默认值 |
| url | object |
远程接口配置,示例:{read:"",add:"",edit:"",delete:""} 其中add、edit、delete属于功能项,不配置url相关功能不会显示 |
|
| columns | array[object] | 列配置,下文会详细介绍 | |
| actions | array[object] |
右上角操作按钮,默认添加"搜索"; 如果url配置了add,则添加"新增"选项 |
|
| imgSaveUrl | string | img类型图片上传地址 | "/api/File/UploadPic" |
| formId | string | 弹出框id | "bode-grid-autoform" |
| formWidth | string | 弹出框宽度,支持px与百分数 |
无富文本编辑器时:40%; 有富文本编辑器时:60% |
| pageIndex | number | 页序号 | 1 |
| pageSize | number | 每页数量 | 15 |
| beforeInit | function | 初始化前执行 | |
| initComplete | function | 初始化后执行 | |
| loadDataComplete | function | 每次数据重新加载后执行 |
| title | string | 表头显示标题 | |
| data | string | 从数据源获取对应的字段名 | |
| type | string |
该列的类型,现支持的类型有: text、textarea、richtext、number、switch、dropdown、 img、datepicker、timepicker、hide、command |
|
| query | boolean | 是否允许查询 | false |
| editor | object | 编辑相关配置,还可以继续完善 | |
| source | object |
dropdown类型下拉数据源,格式: {data:[{value:"xx",text:"vv"}],textField:"xx",valueField:"xx" } |
textField默认"text"; valueField默认"value" |
| sortDisable | boolean | 是否禁止排序 | false |
| render | function(v,d) | 自定义列渲染事件,v表示当前单元格的数据,d表示当前行的数据 | |
| editor | object |
{ap:"hide",ep:"disabled"};ap:新增模式,ep:编辑模式;'hide'表示 隐藏该列,'disabled'表示该列不可编辑 |
全自动数据表格JQuery版的更多相关文章
- 【bird-front】全自动数据表格组件bird-grid
bird-grid是bird-front前端框架中实现的全自动数据表格组件.组件内部处理数据加载.分页.排序.查询.新增.编辑等一系列操作.让业务表格的开发从繁复的增删查改中脱离出来,编码简洁却又功能 ...
- [React]全自动数据表格组件——BodeGrid
表格是在后台管理系统中用的最频繁的组件之一,相关的功能有数据的新增和编辑.查询.排序.分页.自定义显示以及一些操作按钮.我们逐一深入进行探讨以及介绍我的设计思路: 新增和编辑 想想我们最开始写新增 ...
- JQuery Easy Ui dataGrid 数据表格
数据表格 - DataGrid 英文文档:http://www.jeasyui.com/documentation/index.php# 继承$.fn.panel.defaults,使用$.fn.da ...
- JQuery Easy Ui dataGrid 数据表格 ---制作查询下拉菜单
JQuery Easy Ui dataGrid 数据表格 数据表格 - DataGrid 继承$.fn.panel.defaults,使用$.fn.datagrid.defaults重载默认值.. 数 ...
- JQuery Easy Ui dataGrid 数据表格 -->转
转至: http://www.cnblogs.com/cnjava/archive/2013/01/21/2869876.html#events 数据表格 - DataGrid 内容 概况 使用方法 ...
- jquery easyui DataGrid 数据表格 属性
用法 1. <table id="tt"></table> 1. $('#tt').datagrid({ 2. url:'datagrid_d ...
- Jquery EasyUI datagrid后台数据表格生成及分页详解
由于项目原因,网站后台需要对用户信息进行各种操作,有时还需要进行批量操作,所以首先需要将用户信息展示出来,查了不少资料.发现Jquery EasyUI确实是一个不错的选择,功能强大,文档也比较全面,而 ...
- 第二百二十四节,jQuery EasyUI,ComboGrid(数据表格下拉框)组件
jQuery EasyUI,ComboGrid(数据表格下拉框)组件 学习要点: 1.加载方式 2.属性列表 3.方法列表 本节课重点了解 EasyUI 中 ComboGrid(数据表格下拉框)组件的 ...
- 第二百二十二节,jQuery EasyUI,DataGrid(数据表格)组件
jQuery EasyUI,DataGrid(数据表格)组件 学习要点: 1.加载方式 2.分页功能 本节课重点了解 EasyUI 中 DataGrid(数据表格)组件的使用方法,这个组件依赖于 Pa ...
随机推荐
- Postgre SQL连接服务器失败
首先这是登陆postgre sql时提示的错误信息: psql: 无法联接到服务器: Connection refused (0x0000274D/10061) 服务器是否在主机 &qu ...
- STL vector简单用法
初涉c++,此为<算法笔记>中的内容,有待个人理解完善. vector vector翻译为向量,叫做"变长数组"更容易理解. 头文件:#include<vecto ...
- Python-数学篇之计算方法的目录:
目录: 1.出本专题的初衷: 2.参考计算方法的书籍: 3.具体算法的实现: (一)出本专题的初衷: 在我们机械专业的大二上学期课程中,能与计算机沾上边的科目就数<计算方法>了.简化为&q ...
- 使用Gitkraken进行其他Git操作
使用Gitkraken进行其他Git操作 查看某次 commit 的文件改动 使用 Gitkraken 能非常方便的看到任意一次的 commit 对项目文件的改动. 具体操作是:在树状分支图上单击某个 ...
- LCA转换成RMQ
LCA(Lowest Common Ancestor 最近公共祖先)定义如下:在一棵树中两个节点的LCA为这两个节点所有的公共祖先中深度最大的节点. 比如这棵树 结点5和6的LCA是2,12和7的LC ...
- 【转】curl 命令行下载工具使用方法小结
获取curl curl 命令行下载工具 curl的官方网站为: http://curl.haxx.se官方下载页面为:http://curl.haxx.se/download.html 你可能并不清楚 ...
- 【转】这五种方法前四种方法只支持IE浏览器,最后一个方法支持当前主流的浏览器(火狐,IE,Chrome,Opera,Safari)
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- Python调用WIN10语音交互+识别+控制+自定义对话
1 安装库文件 2修改两个地方 最简单的 # 将输入文字转化为语音信号输出 import speech while True: speech.say("请输入:") str = i ...
- Java的快速失败和安全失败
文章转自https://www.cnblogs.com/ygj0930/p/6543350.html 一:快速失败(fail—fast) 在用迭代器遍历一个集合对象时,如果遍历过程中对集合对象的内容进 ...
- Jquery弹窗组件
下面是写的简单的Jquery弹窗组件 暂不支持animate,只能满足一般的弹窗显示隐藏需求,更多功能后续会完善!网上及jquery组件很多这样的弹窗,但是用别人的感觉心里过不去,所以就随便写写,当做 ...