WebGrid 的标头格式

发布于 2024-10-26 03:13:42 字数 1099 浏览 7 评论 0原文

我刚刚读过: http://www.mikesdotnetting.com/Article /154/Looking-At-The-WebMatrix-WebGrid 并查看对 [Optional, Default Value(null)] string header 的引用

(如果您不需要数据库字段名称)

但我不确定如何格式化单元格值。例如,如果我有一个如下所示的 WebGrid:

Column Name          Column Name          Column Name          Column Name          
Cell value           Cell value           Cell value           Cell value           
Cell value           Cell value           Cell value           Cell value           
Cell value           Cell value           Cell value           Cell value           
Cell value           Cell value           Cell value           Cell value           
Cell value           Cell value           Cell value           Cell value           

我想让每个单元格都可单击,并且根据它所在的列,我希望其相应的超链接与另一个单元格的超链接不同。

这可以使用 WebGrid 来完成吗?我已经在 PHP 中完成了此操作,但不知道在哪里查找,也不知道如何使用 WebGrid 来完成此操作。

在搜索 Google、Bing 和 Yahoo!(?) 时,我只看到那些高级 WebGrid 组件的结果,而不是真正 WebGrid 的单个结果,也没有任何有帮助的结果。

I just read: http://www.mikesdotnetting.com/Article/154/Looking-At-The-WebMatrix-WebGrid and see a reference to [Optional, Default Value(null)] string header

Header text if you don't want database field names

But I'm not sure how to format cell values. For example, if I have a WebGrid that looks like this:

Column Name          Column Name          Column Name          Column Name          
Cell value           Cell value           Cell value           Cell value           
Cell value           Cell value           Cell value           Cell value           
Cell value           Cell value           Cell value           Cell value           
Cell value           Cell value           Cell value           Cell value           
Cell value           Cell value           Cell value           Cell value           

I would like to make each Cell clickable, and depending on the column it is in, I would like its corresponding hyperlink to be different from another cell's hyperlink.

Can this be done using WebGrid? I've done this in PHP, but have no idea where to look, or how to do it with WebGrid.

Upon searching Google, Bing and Yahoo!(?), I only see results for those premium WebGrid components, not a single result for the real WebGrid, nor any results that would be of any help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

野却迷人 2024-11-02 03:13:42

在您引用的 Mike 的 DotNetting 文章中,他展示了如何在以下代码行中显示短日期:

format: @<text>@item.DatePublished.ToShortDateString()</text>

由于格式替换了整个单元格,因此您只需放置生成所需 HTML(包括超链接)的代码。由于生成任何复杂的内容可能会使该行代码难以阅读,因此最好编写自己的类/函数来生成所需的代码。我有这样的情况,我的格式行如下所示:

format : @<text>@Html.Raw(NDisplay.displayComment( username, item.AssignedTo, item.NALComment, item.refID, item.Process))</text>,

然后在该函数中:

public static string displayComment( string username, string AssignedTo, string NALComment, int refID, string Process) 
{
    // various junk code removed, testing user and rights
    // here we know we have the right user, he or she needs the edit URL
    // two parameters are passed, first the refID, second the Process (or document)
    string e = "<a href =\"../Process/" + refID.ToString() + "/" + Process +"/\">Edit</a> " + NALComment;

    return e;
}

在每个单元格中,都有一个编辑超链接,后跟文本注释。

In Mike's DotNetting article that you reference, he shows how to display the shortdate in the following line of code:

format: @<text>@item.DatePublished.ToShortDateString()</text>

Since the format replaces the entire cell, you just need to put the code that produces the HTML you want, including hyperlinks. Since to produce anything complicated might make that line of code too painful to read, it might be best to write your own class/function that produces the code you want. I have a situation like that and my format line looks like:

format : @<text>@Html.Raw(NDisplay.displayComment( username, item.AssignedTo, item.NALComment, item.refID, item.Process))</text>,

And then in that function:

public static string displayComment( string username, string AssignedTo, string NALComment, int refID, string Process) 
{
    // various junk code removed, testing user and rights
    // here we know we have the right user, he or she needs the edit URL
    // two parameters are passed, first the refID, second the Process (or document)
    string e = "<a href =\"../Process/" + refID.ToString() + "/" + Process +"/\">Edit</a> " + NALComment;

    return e;
}

In each cell, there's an edit hyperlink, followed by a text comment.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文