We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Show the data correctly

Hi I have the following problem. I want to use the grid of Syncfusion Asp net MVC in my application, but not how to use it in this case, since my table has the following code that allows me to format the data and do not like the grid of Syncfusion. If you could help me on this issue I would appreciate it.

Here's my code, try to simplify it as I see conditional (if) that I formatted the data, as I can do so that I look like

@foreach (var item in Model)
{


@if (item.MedallionComplete == "Medallion")
{

}
else
{

}


@Html.DisplayFor(modelItem => item.ClienteId)


@Html.DisplayFor(modelItem => item.EstadoEquipo)


@Html.DisplayFor(modelItem => item.FechaIngresoEquipo)


@if (item.FechaDespacho == Convert.ToDateTime("01/01/0001"))
{

}
else
{
@Html.DisplayFor(modelItem => item.FechaDespacho)
}


@Html.DisplayFor(modelItem => item.EquipoId)


}



And this is my grid in Syncfusion, but I need to put those conditions to display data as I want.

Thanks for your understanding.




@(Html.EJ().Grid
("Binding")
.Datasource((IEnumerable<object>
)ViewBag.datasource)
.AllowPaging()
.PageSettings(page => { page.PageSize(20); })
.Columns(c =>
{
c.Field("InformeId").HeaderText("N° OT").Add();
c.Field("ClienteId").HeaderText("Cliente").Add();
c.Field("EstadoEquipo").HeaderText("Estado Equipo").Add();
c.Field("FechaIngresoEquipo").HeaderText("Ingreso Equipo").Add();
c.Field("FechaDespacho").HeaderText("Despacho Equipo").Format("{0:dd/MM/yyyy}").Add();
c.Field("EquipoId").HeaderText("Equipo").Add();
c.Field("Serie").HeaderText("N° Serie").Add();
c.Field("Partnumber").HeaderText("Partnumber").Add();
c.Field("OrdenCompra").HeaderText("Orden de Compra").Add();
c.Field("OrdenDespacho").HeaderText("Guía Despacho").Add();
c.Field("Tecnico").HeaderText("Técnico").Add();
c.Field("GuiaIngreso").HeaderText("Guía Ingreso").Add();
c.Field("TipoReparacion").HeaderText("Tipo Reparación").Add();
})
)





<object>

1 Reply

SA Saravanan Arunachalam Syncfusion Team October 22, 2015 12:12 PM UTC

Hi Juan,

Thanks for contacting Syncfusion Support.

We have created the sample for your requirement and download it from the below link:

http://www.syncfusion.com/downloads/support/forum/120847/ze/TableBinding192435997

In the above sample, we used “Table” binding feature of Grid control and passed the formatted data table id to the DataSource “Table” property and the grid is rendered based on the specified formatted data. Please refer to the following code example and online sample for table binding.

<script id="_table1" type="text/template">

    <table>

        . . .

        //Code for Data format

     </table>

    </script>

@(Html.EJ().Grid<TableBinding.OrdersView>("FlatGrid")

        .Datasource(ds => { ds.Table("#_table1"); })

        . . .

)

 

http://mvc.syncfusion.com/demos/web/grid/tablebinding

Regards,

Saravanan A.


Loader.
Live Chat Icon For mobile
Up arrow icon