Modify Displayexpr

Asked

Viewed 36 times

1

I have the following code:

groupItems.AddSimpleFor(m => m.Bcx_codigo).CssClass("lbcod")
                        .Editor(e => e.SelectBox().Width("300px")
                        .DataSource(ContaBancariaController.ListaBancosBuscados)
                        .DisplayExpr("Ban_Nome")
                        .ValueExpr("Bcx_codigo")
                        .ID("ibcod"));;

It results in :

inserir a descrição da imagem aqui

Where I choose what appears to me is in the DisplayExpr, am I correct? , would like to modify the DisplayExpr not to display only the Ban_Nome, but also another field called Bcx_agencia

I wanted something like ("Ban_Nome" + , + "Bcx_agencia"), how can I change the DisplayExpr to do this? and another question, the ValueExpr I choose the data I want to send, I’m correct?

1 answer

3


You can manipulate your DataSource to popular the component with the information you want.

groupItems
    .AddSimpleFor(m => m.Bcx_codigo)
    .CssClass("lbcod")
    .Editor(e => e.SelectBox().Width("300px")
    .DataSource(ContaBancariaController.ListaBancosBuscados
                .Select(x => 
                        new { x.Bcx_codigo, 
                              Display = $"{x.Ban_Nome} - {x.Bcx_Agencia}"
                            }
                        ).ToList())
    .DisplayExpr("Display")
    .ValueExpr("Bcx_codigo")
    .ID("ibcod");
  • That’s exactly what I wanted, thank you very much

  • Just one question, Valueexpr I choose the data I want to send to Bcx_code, I’m sure?

  • That, as well as for the Display, you can put whatever you want into a property and map on ValueExpr().

  • Okay, got it, thanks

  • If it’s not too much to ask, I asked you another question, I think you can help me if I just take a look please: https://answall.com/questions/361247/addir-checkbox-ao-campo-do-datagrid

Browser other questions tagged

You are not signed in. Login or sign up in order to post.