Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
765
igHierarchicalGrid v 2012.1, don't work
posted

Good day.

I have the following problem, I am using igHierarchicalGrid, only the datasource, I get by json, which food from a store procedure, where I need to send the fields from different tables.

At level 1 there is no problem showing me the data, but the second did not show anything, only the fields to create 2 ViewModels this one with the fields you need at level 1, and other fields with level 2 .

I leave a bit of code, and I hope I can help.

 

there is my viewmodels:

level 1:

 public class RegistroApartadoInicial
    {

        [Key]
        [ForeignKey("FraccionamientoViewModel")]
        [Display(Name = "CONTRATO")]
        public string idContrato { get; set; }

        [Display(Name = "CLIENTE")]
        public string idCliente { get; set; }

        [Display(Name = "NOMBRE")]
        public string Nombre { get; set; }

        [Display(Name = "APELLIDO PATERNO")]
        public string ApellidoPaterno { get; set; }

        [Display(Name = "APELLIDO MATERNO")]
        public string ApellidoMaterno { get; set; }

        [Display(Name = "PAQUETE COMERCIAL")]
        public string idPaqueteComercial { get; set; }

        [Display(Name = "ESQUEMA COMERCIAL")]
        public string EsquemaComercial { get; set; }

        [Display(Name = "CARTERA")]
        public string Cartera { get; set; }

        [Display(Name = "ABREVIATURA CARTERA")]
        public string CarteraAbreviatura { get; set; }

        [Display(Name = "MONTO")]
        public decimal? Monto { get; set; }

        [Display(Name = "PAGOS ANTES FINANCIAMIENTO")]
        public decimal? PagosAntesFinanciamiento { get; set; }

        [Display(Name = "MONTO A FINANCIAR")]
        public decimal? Monto_Financiar { get; set; }

        [Display(Name = "INTERES")]
        public Double? Interes { get; set; }

        [Display(Name = "PERIODO PAGOS")]
        public string Periodo_Pagos { get; set; }
       
        public ICollection<FraccionamientoViewModel> ContratoFraccs { get; set; }

    }

this is level 2:

public class FraccionamientoViewModel
    {
        [Key]
        [Display(Name = "FRACCIONAMIENTO")]
        public string idFraccionamiento { get; set; }

       
        [Display(Name = "NOMBRE")]
        public string FraccionamientoNombre { get; set; }

        [Display(Name = "DESCRIPCION")]
        public string FraccionamientoDescripcion { get; set; }

        [ForeignKey("RegistroApartadoInicial")]
        [Display(Name = "CONTRATO")]
        public string idContrato { get; set; }

       
        public RegistroApartadoInicial RegistroApartadoInicial { get; set; }
    }

here my controller:

public ActionResult Apartados(string id)
        {
            var cliente = clientes.GetByID(id);

            ViewBag.idCliente = cliente.idCliente;
            ViewBag.Nombre = cliente.Nombre;
            ViewBag.Ap = cliente.ApellidoPaterno;
            ViewBag.Am = cliente.ApellidoMaterno;
            this.ApartadoInicial(id);

            return View("ApartadoInicial");

        }

public JsonResult ApartadoInicial(string id)
        {
 //aqui utilizo el stored procedure que me trae todos los datos.
            var dato = da.ContratosPorCliente_Select(id);

            return Json(dato, JsonRequestBehavior.AllowGet);
 }

and my view:

@model IQueryable<CxCModels.ViewModels.RegistroApartadoInicial>
@using Infragistics.Web.Mvc;          

<script type="text/javascript">
        $(document).ready(function () {
            var idcliente = document.getElementById("inputCliente").value;
            $.getJSON(
                "/BusquedaCliente/ApartadoInicial",
                { id: idcliente },

                    function (json) {

                        $("#grid2").igGrid("dataSourceObject", json);
                        $("#grid2").igGrid("dataBind");
                    });   
        });
   
    </script>

    <div style=" vertical-align: 200px;">
       

            @(Html.Infragistics().Grid(Model).ID("grid2").Width("800px").AutoGenerateColumns(false).LoadOnDemand(true)
            .PrimaryKey("idContrato").AutoCommit(true).DefaultColumnWidth("150px")
                .Columns(column =>
                {
                    column.For(x => x.idContrato);
                    column.For(x => x.EsquemaComercial);
                    column.For(x => x.CarteraAbreviatura).Width("200px");
                    column.For(x => x.Monto);
                    column.For(x => x.PagosAntesFinanciamiento).Width("200px");
                    column.For(x => x.Monto_Financiar);
                    column.For(x => x.Interes);
                    column.For(x => x.Periodo_Pagos);

                })
            .AutoGenerateLayouts(false)
                .ColumnLayouts(layouts =>
                {
                    layouts.For(x => x.ContratoFraccs).PrimaryKey("idFraccionamiento").ForeignKey("idContrato").DefaultColumnWidth("150px").LoadOnDemand(true).AutoGenerateColumns(false).Columns(childcols1 =>
                    {
                        childcols1.For(x => x.idContrato);
                        childcols1.For(x => x.idFraccionamiento);
                        childcols1.For(x => x.FraccionamientoNombre);
                        childcols1.For(x => x.FraccionamientoDescripcion);

                    });
                })
                .Features(features =>
                {
                    features.Paging().Type(OpType.Local).PagerRecordsLabelTemplate("${startRecord} - ${endRecord} DE ${recordCount} REGISTROS").PageSize(10).FirstPageLabelText("").FirstPageTooltip("Ir a primera pagina").PrevPageLabelText("").PrevPageTooltip("Ir a pagina Anterior").ShowPagerRecordsLabel(true)
                    .LastPageLabelText("").LastPageTooltip("Ir a Ultima pagina").NextPageLabelText("").NextPageTooltip("Ir a Siguiente pagina").PageSizeDropDownLabel("MOSTRAR").PageSizeDropDownTrailingLabel("REGISTROS");
                })
            .Height("400px")
            .DataBind()
            .Render())

    </div>

 I hope anybody helpme. thanks in advance.

this an image of my grid:

Regards