[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 ...
随机推荐
- 转:jQuery 常见操作实现方式
http://www.cnblogs.com/guomingfeng/articles/2038707.html 一个优秀的 JavaScript 框架,一篇 jQuery 常用方法及函数的文章留存备 ...
- How To Write In Sharepoint Log File 怎么对自定义的MOSS代码写日志
How To Write In Sharepoint Log File 怎么对自定义的MOSS代码写日志 Add Microsoft.Office.Server dll in your project ...
- C++pair类型
标准库类型--pair类型定义在utility头文件中定义 本文地址:http://www.cnblogs.com/archimedes/p/cpp-pair.html,转载请注明源地址. 1.pai ...
- Masonry介绍与使用实践(快速上手Autolayout)
MagicNumber -> autoresizingMask -> autolayout 以上是纯手写代码所经历的关于页面布局的三个时期 在iphone1-iphone3gs时代 win ...
- 关于第三方IOS的checkBox框架的使用
*:first-child { margin-top: 0 !important; } body > *:last-child { margin-bottom: 0 !important; } ...
- SQL - 生成指定范围内的随机数
今天按照公司需求,需要做一个sql作业来对数据库定时触发,其中有个难点,就是在sql中需要在1-n中随机出来一个结果. google了半天,找到一个比较好的方式. 写下这个sql: DECLARE @ ...
- XMind快捷键
XMind 是一款非常实用的思维导图软件,可以画各种结构图鱼骨图.二维图.树形图.逻辑图.组织结构图等!下面是常用的快捷键统计! 快捷鍵(Windows) 快捷鍵(Mac) 描述 Ctrl+N Com ...
- linux下修改系统时间
一.查看时间: [root@localhost ~]# date2016年 11月 19日 星期六 12:46:37 CST 二.修改时间,修改系统时间 [root@localhost ~]# dat ...
- Effective Java 66 Synchronize access to shared mutable data
synchronized - Only a single thread can execute a method or block at one time. Not only does synchro ...
- 解读Python发送邮件
解读Python发送邮件 Python发送邮件需要smtplib和email两个模块.也正是由于我们在实际工作中可以导入这些模块,才使得处理工作中的任务变得更加的简单.今天,就来好好学习一下使用Pyt ...