Reputation: 333
I am developing with MVC, and have a view "List"
[...]
var columns = new WebGridColumn[] {
grid.Column("Id"),
grid.Column("Descricao"),
grid.Column("UsuarioModificacao"),
grid.Column("DataModificacao"),
grid.Column("UltimoLogAcesso.DataAcesso"),
grid.Column("UltimoLogAcesso.Ip"),
grid.Column("UrlChamadaAlerta", format: (grid) => string.Format("{Id}")),
grid.Column("FlagBloqueioPainel"),
grid.ButtonColumn("ico_permission.gif", x => Url.Action("ConfirmarExclusao", "PainelChamada", new { id = x.Id } ), updateTargetId: "console"),
I need to format the UrlChamadaAlerta column that should be in this format:
painel.ejis.com.br/?id=<PainelChamada.ID>&token=<PainelChamada.GuidPainelChamada >
I will use the ID and the Guid that are in the model "PainelChamada"
public int Id {get; set;}
public System.Guid Guid { get; set; }
create routes is right, but for now the format will suit my intent. Obs .: will be used as the format certain properties that would be made to the routes need not be perfect. My Format is wrong, but my difficulty is to set the correct expression.
Upvotes: 0
Views: 52
Reputation: 56688
Something like this should work.
grid.Column("UrlChamadaAlerta",
format: dataItem =>
string.Format("painel.ejis.com.br?id={0}&token={1}",
dataItem.Id,
dataItem.Guid),
Note that lambda in format parameter expects a data item, which gives you a direct access to the fields you need.
Upvotes: 1