ASP.NET MVC4开发指南_vue mvc

ASP.NET MVC4开发指南_vue mvcWhatistheWebGrid?TheWebGridisahelperthatwasincludedonthenewBeta1versionofASP.NETMVC3(Changescanhappenssinceitisabetaversion)thatenableustoshowdataeasily.Withasimp…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

What is the WebGrid?

The WebGrid is a helper that was included on the new Beta 1 version of ASP.NET MVC 3 (Changes can happens since it is a beta version) that enable us to show data easily.

With a simple command @grid.getHtml() we have as return a populated table, with paging, sorting and alternated lines. Want more? yes, it follows the webstandards.

The WebGrid constructor takes a number of parameters. Only one is mandatory. Here’s an explanation of all of them:

System.Collections.Generic.IEnumerable sourceThe collection of objects

System.Collections.Generic.IEnumerable columnNames = nullThe names of the columns appearing in the grid

string defaultSort = null

The name of the column to sort the grid by default

int rowsPerPage = 10The number of rows to display per page is paging is enabled

bool canPage = trueDetermines if the WebGrid can be paged

bool canSort = trueDetermines if the WebGrid can be sorted

string ajaxUpdateContainerId = nullThe id of the containing element for Ajax paging and sorting support

string ajaxUpdateCallback = nullThe callback function for Ajax paging and sorting support

string fieldNamePrefix = nullThe value which prefixes the default querystring fields

string pageFieldName = nullA value that replaces the default querystring page field

string selectionFieldName = nullA value that replaces the default querystring row field

string sortFieldName = nullA value that replaces the default querystring sort field

string sortDirectionFieldName = nullA value that replaces the default querystring sortdir field

The GetHtml method renders the grid. To render a simple grid with no formatting, use the following code. I’m using the model that’s being passed in to the view for these examples.

Controller:

public ActionResult WebGrid()

{

return View(VideoRepository.FindAll().OrderByDescending(v=>v.CreateTime));

}

View:

@model IEnumerable

@{

ViewBag.Title = “WebGrid”;

Layout = “~/Areas/Admin/Views/Shared/Layout.cshtml”;

}

WebGrid

@{

var grid = new WebGrid(Model, rowsPerPage: 2);

@grid.GetHtml(

tableStyle: “data-table”,

columns: grid.Columns(

grid.Column(“Title”),

grid.Column(header: “Image”, format: (item) => Html.Raw(string.Format(“%7B0%7D%5C%22“, item.ImageName))),

grid.Column(“CreateTime”, format: (item) => string.Format(“{0:d}”, item.CreateTime))

)

)

}

CSS:

/* data-table */

.data-table

{

border: #DDDDDD 1px solid;

width: 100%;

background:#FFF;

}

.data-table thead th

{

padding: 5px 10px;

text-align: left;

border: 1px solid #DDDDDD;

border-bottom: 1px solid #C1C8D2;

background-color: #F2F4F6;

font-size: 13px;

}

.data-table td

{

line-height: 20px;

padding: 5px 10px;

border: 1px solid #DDDDDD;

}

.data-table tr:hover

{

background-color: #F3F3F3;

}

.data-table td a

{

text-decoration: underline;

}

.data-table tfoot td

{

font-weight: bold;

padding: 10px 0;

text-align: center;

}

.data-table tfoot a

{

border: 1px solid #9AAFE5;

color: #2E6AB1;

display: inline-block;

margin: 0 2px;

padding: 0 5px;

text-decoration: none;

}

Result:

2509349417392372736.png

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/188881.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • mac Python安装pybloomfilter 出现找不到libcrypto的问题

    mac Python安装pybloomfilter 出现找不到libcrypto的问题获取新的库brewupdate&&brewupgrade&&brewinstallopensslcd/usr/local/Cellar/openssl/1.0.2t/libsudocplibssl.1.0.0.dyliblibcrypto.1.0.0.dylib/usr/local/lib/建立新的连接sudoln-sli…

    2022年6月28日
    37
  • phpstorm 激活码 2021【在线注册码/序列号/破解码】

    phpstorm 激活码 2021【在线注册码/序列号/破解码】,https://javaforall.net/100143.html。详细ieda激活码不妨到全栈程序员必看教程网一起来了解一下吧!

    2022年3月18日
    41
  • 全新安装Mac OSX 开发者环境 同时使用homebrew搭建 (LNMP开发环境)

    全新安装Mac OSX 开发者环境 同时使用homebrew搭建 (LNMP开发环境)

    2021年5月11日
    220
  • 思科 计算机网络 期末考试答案

    思科 计算机网络 期末考试答案1.以下哪个域名是顶级域的一个示例?A.root.cisco.comB.www.cisco.comC.cisco.comD…com2.第2层数据封装有哪三个主要功能?(请选择三项。)A.将位组定界为帧B.通过冲突检测方法纠正错误C.在介质中放置和删除帧D.将位转换为数据信号E.通过CRC计算检测错误F.数据链路层寻址G.使用端口号控制会话3.管理员在发出ping命令之后在交换机上使用Ctrl-Shift-6键组合。使用这些按键有什么用途?A.允许用户完成命令B.中

    2022年7月23日
    17
  • SSM-Mybatis(2)

    SSM-Mybatis(2)日志如果一个数据库操作,出现了异常,我们需要排错,日志就是最好的助手曾经:sout,debug现在:日志工厂掌握STDOUT_LOGGINGLOG4Jlog4j什么是Log4j?我们可以控制日志信息输送的目的地是控制台我们也可以控制每一条日志的输出格式通过定义每一条日志信息的级别,我们能够更加细致地控制日志的生成过程通过一个配置文件来灵活地进行配置,而不需要修改应用的代码。分页减少数据量selsect * from user limit startIndex,pageS

    2022年8月9日
    9
  • opencv3编程入门_java基础与入门教程

    opencv3编程入门_java基础与入门教程——韦访 201810111、概述想学习图像处理,不管是机器学习也好,深度学习也好,不会点OpenCV好像有点说不过去吧?所以,现在开始OpenCV的学习。2、读写图片先从图片的读写开始,opencv读取图片的函数是imread,默认情况下,imread函数返回BGR格式的图像,可以用imwrite函数将数据写到本地。下面的代码会将JPG图片转成PNG。import…

    2022年10月3日
    3

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号