No data on grid

I have tried to load a simple List<object> but all I get is 

<grid id="LocalData"></grid> This is my cs.


public ActionResult AddInvitePL(string tokenKey)

{
    UtilidadesViewModel model = new UtilidadesViewModel();

    Business.ConfirmacionTarifa objConfirmacionTarifa = new Business.ConfirmacionTarifa();
    List<opConfirmacionTarifa> DatosRCFirmados = objConfirmacionTarifa.ConsultarConfirmacionTarifa(x => x.IdProveedorLogistico != 0).ToList();

    // Asignar los datos mapeados al modelo
    model.opConfirmacionTarifas = DatosRCFirmados;

    return PartialView(model);
}

This is my cshtml

            <div class="modal-body" style="height: 350px;" id="datosTabla">
                <button type="button" class="btn btn-success" onclick="abrirCaptura();">Agregar Proveedor</button>
                @Html.EJS().Grid("LocalData").DataSource(Model.opConfirmacionTarifas).Columns(col =>
                    {
                        col.Field("opConfirmacionTarifa .TripId").HeaderText("Trip ID").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("120").Add();
                    }).AllowPaging().Render()


            </div>


1 Reply

VK Vasanthakumar K Syncfusion Team June 17, 2024 06:02 PM UTC

Hi Mario Malvido,


Greetings from Syncfusion support.


We have validated your query and understand that you are facing an issue with rendering a partial view grid only appending the dom with the tag element (<grid id="LocalData"></grid>) on MVC framework. We were able to replicate the issue only when we didn’t have the main page view to render the partial view grid. We suspect that you are also facing a similar issue. Generally, for every partial view render, there must be a main page view. The same principle applies to grid rendering as well. Please use the main view containing the partial view for rendering the partial view grid. We have prepared a sample for your reference. Please refer to the below code example and sample for more details.


If you still face issues, even after applying the main view for rendering the partial view, please provide a sample of the issue being replicated or try to replicate the issue using our shared sample for further validation on our end.


[code example]

[cs code example]

 

public ActionResult Index() // main view

{

    List<OrdersDetails> model = orddata;

    return View(model);

}

public ActionResult Grid() // partial view

{

    List<OrdersDetails> model = orddata;

    return PartialView(model);

}

 

[cshtml code example]

 

@model IEnumerable<mvc_ej2.Controllers.OrdersDetails>

<div class="control-section">

    @Html.Partial("Grid", Model) // main view

</div>

 

@model IEnumerable<mvc_ej2.Controllers.OrdersDetails>

@{

    var DataSource = Model;

}

<div class="control-section">

     // partial view

    @Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)DataSource).Columns(col =>

{

    . . . . . . .

}).Height("400").AllowPaging().Render()

</div>


Sample: please find the attachment.


Regards,

Vasanthakumar K


Attachment: 188804mvcpartialgriddomelementsnotappendnotrender_d306c2d9.zip

Loader.
Up arrow icon