1.columns

  1. <% Html.Telerik().Grid(Model)
  2. .Name("Orders")
  3. .Columns(columns =>
  4. {
  5. //绑定列名
  6. columns.Bound(o => o.OrderID);
  7. //隐藏字段
  8. columns.Bound(o => o.OrderID).Hidden(true);
  9. //绑定列标题
  10. columns.Bound(o => o.OrderDate).Title("Order");
  11. //添加样式
  12. columns.Bound(o => o.OrderID).HeaderHtmlAttributes(new {@class="order-id-column"}});
  13. //设置列宽
  14. 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");
  15. //Template column which shows an action link
  16. columns.Template(o =>
  17. {
  18. %>
  19. <%= Html.ActionLink("Edit", "Home", new { id = o.OrderID }) %>
  20. <%
  21. }).Title("Edit");
  22. })
  23. .Render();
  24. %>

js

  1. //列标题的复选框全选实现
  2. function checkeAll(e) {
  3. $("input[name='chkBox']").attr("checked", e.checked);
  4. }

2.Paging 分页

  1. <%= Html.Telerik().Grid(Model)
  2. .Name("Grid")
  3.   .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. 自定义

  1. //----Defining a custom server command
  2. <%= Html.Telerik().Grid<Order>(Model)
  3. .Name("Grid")
  4. .Columns(columns =>
  5. {
  6. columns.Command(commands =>
  7. {
  8. // Declare a custom command named "showDetails"
  9. commands.Custom("showDetails")
  10. // Set the text which the command button will display
  11. .Text("Show details")
  12. // Specify the action method which the command will invoke
  13. .Action("ShowDetails", "Home")
  14. // Specify which properties of the data item will be passed as action method arguments
  15. .DataRouteValues(route =>
  16. {
  17. // Send the OrderID property of the data item as "orderID" parameter
  18. route.Add(o => o.OrderID).RouteKey("orderID");
  19. });
  20. })
  21. })
  22. %>
  23.  
  24. //----Handling the custom command
  25. // The "orderID" argument will come from the OrderID property. Defined via DataRouteValues
  26. public ActionResult ShowDetails(int orderID)
  27. {
  28. var northwind = new NorthwindDataContext();
  29. // Get the order by "orderID"
  30. var order = northwind.Orders.FirstOrDefault(o => o.OrderID == orderID);
  31.  
  32. // Display a some view which will use the order
  33. return View(order);
  34. }

[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 2013 自定义模板页后在列表里修改不了视图

    前言 最近系统从2010升级至2013,有自定义模板页.突然发现在列表中切换不了视图,让我很费解. 我尝试过以下解决方案: 去掉自定义css 去掉自定义js 禁用所有自定义功能 结果都没有效还是一样的 ...

  2. EL表达式概述

    E L(Expression Language) 目的:为了使JSP写起来更加简单.表达式语言的灵感来自于 ECMAScript 和 XPath 表达式语言,它提供了在 JSP 中简化表达式的方法. ...

  3. Mac上的软件使用介绍

    目录大纲: Drop to GIF Parallels Desktop 1.Drop to GIF 功能:将视频文件可以生产动态图gif文件 网址在github上:https://github.com ...

  4. virt manager 提示权限不允许(ubuntu)

    问题描述: 新安装virt manager 打开提示权限不允许(ubuntu 15.04); 提示检查libvirt-bin包是否安装:libvirtd服务是否已运行:当前用户是否在libvirtd组 ...

  5. windows 注册表编程

    例子:将本地计算机的Monitor ID写入到注册表中 (1)获取MonitorID BOOLEAN DeviceMonitorService::EnumClassDevice(const GUID ...

  6. LeetCode 4 Median of Two Sorted Arrays (两个数组的mid值)

    题目来源:https://leetcode.com/problems/median-of-two-sorted-arrays/ There are two sorted arrays nums1 an ...

  7. DEV 财务货币格式单元格

    在用友金蝶等财务软件中,经常需要输入货币类型的数据, 那么这种输入框要如何制作呢? 扩展DataGridView 的功能  出自在天空飞翔博客 http://www.cnblogs.com/micha ...

  8. saltstack通过salt.client执行命令(转)

    利用saltstack的salt.client模块可以在python的命令行下或者python脚本里执行相应的salt命令 master端想要执行类似 salt '*' cmd.run 'uptime ...

  9. python 练习购物车小程序

    # -*- coding:utf-8 -*- shp = [ ['iphone',5000], ['offee',35], ['shoes',800] ] pric_list = [] e = int ...

  10. mysql force index() 强制索引的使用

    mysql force index() 强制索引的使用 之前跑了一个SQL,由于其中一个表的数据量比较大,而在条件中有破坏索引或使用了很多其他索引,就会使得sql跑的非常慢... 那我们怎么解决呢? ...