[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 ...
随机推荐
- 实验12:Problem F: 求平均年龄
Home Web Board ProblemSet Standing Status Statistics Problem F: 求平均年龄 Problem F: 求平均年龄 Time Limit: ...
- Sharepoint学习笔记—习题系列--70-573习题解析 -(Q127-Q130)
Question 127You create a custom list named Products.You need to perform a Representational State Tra ...
- Android Java类编写规范+优化建议
本文仅是我个人在实际开发中习惯的编写方式,当然这种方式也是来自很多官方的推荐,所以在一定程度上是可以被模仿套用的.本文将不定期更新~ 零.指导原则 优先保证可读性,不要过分追求代码艺术和效率 在可读性 ...
- 关于https的Error:Error Domain=NSURLErrorDomain Code=-1012
昨天闲着没事就随便搞点demo,随便找了一个https的接口,运行之后,一直发现Error Domain=NSURLErrorDomain Code=-1012.好奇怪,请求https的配置我基本都配 ...
- iOS开发过程中,触控板的使用技巧
1.在Storyboard鼠标右键可以直接拖线的,如果你用的是外接的第三方鼠标,没必要按着 control 键再用鼠标左键拖线 如果是触控板的话,双指按下去就可以直接拖线,带3Dtouch功能的触控板 ...
- LeetCode 4 Median of Two Sorted Arrays (两个数组的mid值)
题目来源:https://leetcode.com/problems/median-of-two-sorted-arrays/ There are two sorted arrays nums1 an ...
- nyoj 284 坦克大战 简单搜索
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=284 题意:在一个给定图中,铁墙,河流不可走,砖墙走的话,多花费时间1,问从起点到终点至少 ...
- python基础入门
Python简介 python是吉多·范罗苏姆发明的一种面向对象的脚本语言,可能有些人不知道面向对象和脚本具体是什么意思,但是对于一个初学者来说,现在并不需要明白.大家都知道,当下全栈工程师的概念很火 ...
- Linux下集群的搭建
1.集群的简介: 集群(cluster)技术是一种较新的技术,通过集群技术,可以在付出较低成本的情况下获得在性能.可靠性.灵活性方面的相对较高的收益,其任务调度则是集群系统中的核心技术. 如果一个事情 ...
- Best Time to Buy and Sell Stock II
Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...