[4]Telerik Grid 简单使用方法
1.columns
- <% Html.Telerik().Grid(Model)
- .Name("Orders")
- .Columns(columns =>
- {
- //绑定列名
- columns.Bound(o => o.OrderID);
- //隐藏字段
- columns.Bound(o => o.OrderID).Hidden(true);
- //绑定列标题
- columns.Bound(o => o.OrderDate).Title("Order");
- //添加样式
- columns.Bound(o => o.OrderID).HeaderHtmlAttributes(new {@class="order-id-column"}});
- //设置列宽
- columns.Bound(o => o.OrderID).Width();
//自定义控件(以下为复选框,自定义了列标题为复选框,可供全选)
columns.Bound(o => o.OrderID)
.ClientTemplate("<input type='checkbox' name='chkBox' value='<#=ID#>' />")
.HeaderTemplate("<input type='checkbox' name='checkeAll' value='all' onclick='checkeAll(this)' />");
//时间格式化
columns.Bound(o => o.OrderDate).Format("{0:dd/MM/yyyy}");
//格式化
columns.Bound(c => c.CustomerID).Format( "<img src='>" + Url.Content("~/Content/Images/Customers/")
+ "{0}.jpg' alt='{0}' />" ).Encoded(false).Title("Avatar");- //Template column which shows an action link
- columns.Template(o =>
- {
- %>
- <%= Html.ActionLink("Edit", "Home", new { id = o.OrderID }) %>
- <%
- }).Title("Edit");
- })
- .Render();
- %>
js
- //列标题的复选框全选实现
- function checkeAll(e) {
- $("input[name='chkBox']").attr("checked", e.checked);
- }
2.Paging 分页
- <%= Html.Telerik().Grid(Model)
- .Name("Grid")
- .Pageable() //1.启用分页功能
.Pageable(pager => pager.PageTo(10)) //2.设置按10条分页
.Pageable(pager => pager.Enabled((bool)ViewData["enablePaging"]))
.Pageable(pager => pager.PageSize(20))
.Pageable(pager => pager.Position(GridPagerPosition.Top))
.Pageable(pager => pager.Total((int)ViewData["total"]))
.Pageable(pager => pager.Style(GridPagerStyles.PageInput | GridPagerStyles.Numeric))
%>
3. 自定义
- //----Defining a custom server command
- <%= Html.Telerik().Grid<Order>(Model)
- .Name("Grid")
- .Columns(columns =>
- {
- columns.Command(commands =>
- {
- // Declare a custom command named "showDetails"
- commands.Custom("showDetails")
- // Set the text which the command button will display
- .Text("Show details")
- // Specify the action method which the command will invoke
- .Action("ShowDetails", "Home")
- // Specify which properties of the data item will be passed as action method arguments
- .DataRouteValues(route =>
- {
- // Send the OrderID property of the data item as "orderID" parameter
- route.Add(o => o.OrderID).RouteKey("orderID");
- });
- })
- })
- %>
- //----Handling the custom command
- // The "orderID" argument will come from the OrderID property. Defined via DataRouteValues
- public ActionResult ShowDetails(int orderID)
- {
- var northwind = new NorthwindDataContext();
- // Get the order by "orderID"
- var order = northwind.Orders.FirstOrDefault(o => o.OrderID == orderID);
- // Display a some view which will use the order
- return View(order);
- }
[4]Telerik Grid 简单使用方法的更多相关文章
- MySQL笔记-最简单的方法来解决找不到mysqld.sock文件的问题
首先,环境:ubuntu 14.04,采用apt-get的方式安装的,手动安装可能路径设置稍有区别. 1.安装MySQL后,用命令行首次启动时发现找不到Mysqld.sock文件,提示: ERROR ...
- mfc显示静态图片最简单的方法
一致都是研究如何调用opencv显示动态图片,但是很多时候在显示图标的时候,都是需要显示静态图片,现在将最简单的方法总结下: 1.添加picture控件 2.添加资源,要求为bmp 3.修改属性 结果 ...
- ECshop设置301最快捷最简单的方法
ECshop设置301最快捷最简单的方法 在 init.php中加入以下代码 if (strtolower($_SERVER['SERVER_NAME'])!='www.fz1688.com') { ...
- git 的简单使用方法
git 的简单使用方法1. 服务器 安装完成2. ssh 中的账号创建完成3. 创建 ssh 账号,会在 ssh 的安装目录下的home 目录里面,多了用户家目录4. 进入该目录 ,创建一个新的文件夹 ...
- JavaScript,一个超级简单的方法判断浏览器的内核前缀
先说明,此处的方法是说超级简单的方法,不是指代码超级少,而是用非常简单的知识点,只要懂得怎么写JavaScript的行内样式就可以判断. 大家应该还记得JavaScript行内样式怎么写吧?(看来我是 ...
- NET MVC1项目升级到MVC2最简单的方法
NET MVC1项目升级到MVC2最简单的方法 把MVC1项目升级到MVC2,最简单的做法如下: 新建MVC2项目 新建一个MVC2项目,把原来MVC1的项目文件全部拷贝到新建MVC2项目目录里,依照 ...
- js 获取当天23点59分59秒 时间戳 (最简单的方法)
js 获取当天23点59分59秒 时间戳 (最简单的方法) new Date(new Date(new Date().toLocaleDateString()).getTime()+24*60*60* ...
- [ASP.NET]更简单的方法:FormsAuthentication登录ReturnUrl使用绝对路径
转自:http://www.cnblogs.com/dudu/p/formsauthentication-returnurl-absoluteuri.html [ASP.NET]更简单的方法:Form ...
- ASP.Net MVC_DotNetZip简单使用方法,解决文件压缩的问题[转]
准备工作: 在vs工具栏中找到NuGet 下载DotNetZip 现在就可以使用DotNetZip强大的类库了,在这里我给出一些简单的使用. ? 1 2 3 4 5 6 7 8 9 10 11 ...
随机推荐
- SharePoint 2013 自定义模板页后在列表里修改不了视图
前言 最近系统从2010升级至2013,有自定义模板页.突然发现在列表中切换不了视图,让我很费解. 我尝试过以下解决方案: 去掉自定义css 去掉自定义js 禁用所有自定义功能 结果都没有效还是一样的 ...
- EL表达式概述
E L(Expression Language) 目的:为了使JSP写起来更加简单.表达式语言的灵感来自于 ECMAScript 和 XPath 表达式语言,它提供了在 JSP 中简化表达式的方法. ...
- Mac上的软件使用介绍
目录大纲: Drop to GIF Parallels Desktop 1.Drop to GIF 功能:将视频文件可以生产动态图gif文件 网址在github上:https://github.com ...
- virt manager 提示权限不允许(ubuntu)
问题描述: 新安装virt manager 打开提示权限不允许(ubuntu 15.04); 提示检查libvirt-bin包是否安装:libvirtd服务是否已运行:当前用户是否在libvirtd组 ...
- windows 注册表编程
例子:将本地计算机的Monitor ID写入到注册表中 (1)获取MonitorID BOOLEAN DeviceMonitorService::EnumClassDevice(const GUID ...
- LeetCode 4 Median of Two Sorted Arrays (两个数组的mid值)
题目来源:https://leetcode.com/problems/median-of-two-sorted-arrays/ There are two sorted arrays nums1 an ...
- DEV 财务货币格式单元格
在用友金蝶等财务软件中,经常需要输入货币类型的数据, 那么这种输入框要如何制作呢? 扩展DataGridView 的功能 出自在天空飞翔博客 http://www.cnblogs.com/micha ...
- saltstack通过salt.client执行命令(转)
利用saltstack的salt.client模块可以在python的命令行下或者python脚本里执行相应的salt命令 master端想要执行类似 salt '*' cmd.run 'uptime ...
- python 练习购物车小程序
# -*- coding:utf-8 -*- shp = [ ['iphone',5000], ['offee',35], ['shoes',800] ] pric_list = [] e = int ...
- mysql force index() 强制索引的使用
mysql force index() 强制索引的使用 之前跑了一个SQL,由于其中一个表的数据量比较大,而在条件中有破坏索引或使用了很多其他索引,就会使得sql跑的非常慢... 那我们怎么解决呢? ...