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 简单使用方法的更多相关文章

  1. MySQL笔记-最简单的方法来解决找不到mysqld.sock文件的问题

    首先,环境:ubuntu 14.04,采用apt-get的方式安装的,手动安装可能路径设置稍有区别. 1.安装MySQL后,用命令行首次启动时发现找不到Mysqld.sock文件,提示: ERROR ...

  2. mfc显示静态图片最简单的方法

    一致都是研究如何调用opencv显示动态图片,但是很多时候在显示图标的时候,都是需要显示静态图片,现在将最简单的方法总结下: 1.添加picture控件 2.添加资源,要求为bmp 3.修改属性 结果 ...

  3. ECshop设置301最快捷最简单的方法

    ECshop设置301最快捷最简单的方法 在 init.php中加入以下代码 if (strtolower($_SERVER['SERVER_NAME'])!='www.fz1688.com') { ...

  4. git 的简单使用方法

    git 的简单使用方法1. 服务器 安装完成2. ssh 中的账号创建完成3. 创建 ssh 账号,会在 ssh 的安装目录下的home 目录里面,多了用户家目录4. 进入该目录 ,创建一个新的文件夹 ...

  5. JavaScript,一个超级简单的方法判断浏览器的内核前缀

    先说明,此处的方法是说超级简单的方法,不是指代码超级少,而是用非常简单的知识点,只要懂得怎么写JavaScript的行内样式就可以判断. 大家应该还记得JavaScript行内样式怎么写吧?(看来我是 ...

  6. NET MVC1项目升级到MVC2最简单的方法

    NET MVC1项目升级到MVC2最简单的方法 把MVC1项目升级到MVC2,最简单的做法如下: 新建MVC2项目 新建一个MVC2项目,把原来MVC1的项目文件全部拷贝到新建MVC2项目目录里,依照 ...

  7. js 获取当天23点59分59秒 时间戳 (最简单的方法)

    js 获取当天23点59分59秒 时间戳 (最简单的方法) new Date(new Date(new Date().toLocaleDateString()).getTime()+24*60*60* ...

  8. [ASP.NET]更简单的方法:FormsAuthentication登录ReturnUrl使用绝对路径

    转自:http://www.cnblogs.com/dudu/p/formsauthentication-returnurl-absoluteuri.html [ASP.NET]更简单的方法:Form ...

  9. ASP.Net MVC_DotNetZip简单使用方法,解决文件压缩的问题[转]

    准备工作: 在vs工具栏中找到NuGet   下载DotNetZip   现在就可以使用DotNetZip强大的类库了,在这里我给出一些简单的使用. ? 1 2 3 4 5 6 7 8 9 10 11 ...

随机推荐

  1. 响应式SharePoint模版页

    一张好的皮肤显然的会给你的项目加分不少.特别是大部分的项目,UI甚至可以决定成败. SharePoint在这方面一直都做得不好,曾经我有好多项目都是坐在美工旁边来一起修改样式.痛苦的经历. 不久以前, ...

  2. HDFS简单入门

    本文地址:http://www.cnblogs.com/archimedes/p/hadoop-simple.html,转载请注明源地址. 欢迎关注我的个人博客:www.wuyudong.com, 更 ...

  3. UITabBarController 微信

    AppDelegate.m #import "AppDelegate.h" #import "FirstViewController.h" #import &q ...

  4. UINavigationBar 和 UINavigationItem的属性设置

    #import "RootViewController.h" @interface RootViewController () @end @implementation RootV ...

  5. UnityShader之固定管线Fixed Function Shader【Shader资料3】

    Fixed function shader简介:  属于固定渲染管线 Shader, 基本用于高级Shader在老显卡无法显示时的情况.使用的是ShaderLab语言,语法与微软的FX files 或 ...

  6. iOS之 PJSIP静态库编译(三)

    dada哪个所有静态库编译完成后还是不能运行那个demo,提示你找不到arm**.a 你lipo后要记得吧合并成.a  名字更改成你最后编译版本生成的.a名字....... 或者吧所有库add到你的工 ...

  7. Reveal常用技巧(翻译来自Reveal官网blog)

    翻译来自官网:http://revealapp.com/blog/reveal-common-tips-cn.html 以下基于Reveal 1.6. 用于快速上手的内置应用 刚刚下载Reveal,啥 ...

  8. LeetCode 1 Two Sum(二分法)

    题目来源:https://leetcode.com/problems/two-sum/ Given an array of integers, find two numbers such that t ...

  9. android媒体文件扫描

    项目中可能有这样的需求:下载或导入.导出的图片.音乐等媒体文件,需要马上能在图库或本地视屏播放器中显示出来,或者要能在媒体数据库中查询到媒体文件的相关信息,这时我们就得主动通知系统扫描新的媒体文件了. ...

  10. Wing IDE 5 的破解

    Wing IDE 百度百科 1.安装好Python,已测的是Python 2.7.10: 2.新建一个py文件CalcActivationCode.py(名字自己随便取): 3.CalcActivat ...