本文介绍了MvcContrib GridModel:是否有可能在GridModel做ActionSyntax的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个code在使用ActionSyntax我的aspx文件,我想用一个GridModel代替,但我不知道该怎么做。

I have a code in my aspx file which uses ActionSyntax, and i want to use a GridModel instead, but i don't know how to do that.

下面是我的aspx文件的样本:

Here is a sample of my aspx file :

<% Html.Grid(ViewData.Model).Columns(column => {
   column.For(x => x.Id).Named("N° de contrat");
   column.For(x => x.SubscriptionDate).Format("{0:d}").Named("Date de souscription");
   column.For(x => x.SubscriptionOrigin).Named("Source");
   column.For(x => x.Agent).Named("Agence(*)");
   column.For(x => x.Agent).Named("Agent");
   column.For(x => x.Subscriber).Named("Souscripteur");
   column.For(x => x.ProductTitle).Named("Produit");
   column.For(x => x.NbBeneficiaries).Named("Nombre de bénéficiaires");
   column.For(x => x.Price).Named("Montant du contrat");
   column.For("PDF").Named("").Action(p => {%> <td><img src="../Content/Images/pdf.gif" /></td> <%});
   column.For("Mail").Named("").Action(p => {%> <td><img src="../Content/Images/mail.gif" /></td> <%});
   column.For("Attestation").Named("").Action(p => {%> <td><img src="../Content/Images/attestation.gif" /></td> <%});
   column.For("Poubelle").Named("").Action(p => {%> <td><img src="../Content/Images/poubelle.png" /></td> <%});
   }).Attributes(id => "subList").Render(); %>

和我想要做的:

<%= Html.Grid(ViewData.Model).WithModel(new MyGridModel()) %>

但我不知道如何在cs文件呈现此ActionSyntax部分:

But i don't know how to render this ActionSyntax part in a .cs file :

 column.For("PDF").Named("").Action(p => {%> <td><img src="../Content/Images/pdf.gif" /></td> <%});
 column.For("Mail").Named("").Action(p => {%> <td><img src="../Content/Images/mail.gif" /></td> <%});
 column.For("Attestation").Named("").Action(p => {%> <td><img src="../Content/Images/attestation.gif" /></td> <%});
 column.For("Poubelle").Named("").Action(p => {%> <td><img src="../Content/Images/poubelle.png" /></td> <%});

有人有什么想法?

Someone have any idea ?

感谢。

推荐答案

好吧,我找到了解决办法!这里有一个例子为列PDF:

Ok i found the solution ! Here is an example for the column "PDF" :

在我GridModel:

In my GridModel :

Column.For("PDF").Named("").Action(p => GetPdfColumn());

而GetPdfColumn():

And the GetPdfColumn() :

private void GetPdfColumn()
    {
        HttpContext.Current.Response.Write(@"<td><img src='../Content/Images/pdf.gif' /></td>");
    }

就这么简单。

这篇关于MvcContrib GridModel:是否有可能在GridModel做ActionSyntax的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 09:19