This is a migrated thread and some comments may be shown as answers.

Hierachy grid with combobox on popup editing

3 Answers 102 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ross
Top achievements
Rank 1
Ross asked on 15 Aug 2016, 02:48 AM

Hello I have a page with a listview, when an item is selected, 5 grid are filtered, nested on each grid is a subgrid (in the images attached you could see it better) in this subgrid one column has a combobox, I need that when an item on the listview is selected this combobox rebind the data. But it only happens when the method is called when the page is loaded, even the method is called and executed with out errors the combobox remains with the original data.

Below is the combobox:

@model ContabilidadSinLios.Models.CatalogoCuentasViewModel
 
 @(Html.Kendo().ComboBox()
        .Name("CatalogoCuentas")
        .DataValueField("CatalogoCuentaId")
        .DataTextField("Nombre")
        .Height(100)
        .BindTo((System.Collections.IEnumerable)ViewData["catalogos"])
        .HtmlAttributes(new { style = "width: 330px !important; font-size: 11px; " })
        .Suggest(true)
        .MinLength(1)
        .Filter(FilterType.Contains)
    )

And here is the one of the grids:

@(Html.Kendo().Grid<EgresosViewModel>()
                   .Name("cdfie")
                   .Scrollable(s => s.Enabled(true).Height("auto"))
                   .AutoBind(false)
                   .Columns(columns =>
                   {
                       columns.Template(t => { })
                       .ClientTemplate("#=UUID#")
                       .Title("UUID").Hidden(true)
                       .Width(100);
                       columns.Bound(f => f.EstatusSAT).Filterable(false).Title("Estatus SAT").Width(80);
                       columns.Bound(f => f.FechaEmision).Title("Fecha Emisión").Filterable(false).Format("{0:d}").Width(100);
                       columns.Bound(f => f.RFCReceptor).Hidden(true);
                       columns.Bound(f => f.RFCEmisor).Title("RFC Emisor").Width(120);
                       columns.Bound(f => f.NombreEmisor).Title("Nombre Emisor").Width(250);
                       columns.Bound(f => f.SubTotal).Filterable(false).Width(80).Format("{0:c}");
                       columns.Bound(f => f.Descuento).Filterable(false).Width(80).Format("{0:c}");
                       columns.Bound(f => f.IVA16).Title("IVA 16%").Filterable(false).Width(80).Format("{0:c}");
                       columns.Bound(f => f.IEPS).Filterable(false).Width(80).Format("{0:c}");
                       columns.Bound(f => f.RetenidoIVA).Filterable(false).Title("IVA Retenido").Width(120).Format("{0:c}");
                       columns.Bound(f => f.RetenidoISR).Filterable(false).Title("ISR Retenido").Width(120).Format("{0:c}");
                       columns.Bound(f => f.Total).Filterable(true).Width(120).Format("{0:c}");
                       columns.Bound(f => f.MetodoPago).Filterable(false).Width(120).Title("Método de Pago");
                   })
                   .Events(e =>
                        {
                            e.DataBound("onDataBoundEgreso");
                        })
                   .Pageable(pageable => pageable.Refresh(true))
                   .Sortable()
                   .Selectable()
                   .Navigatable()
                   .Resizable(resize => resize.Columns(true))
                   .ClientDetailTemplateId("ConceptosEgresos_DetailTemplate")
                   .DataSource(dataSource => dataSource
                   .Ajax()
                   .PageSize(15)
                   .Model(m =>
                   {
                       m.Id(f => f.UUID);
                       m.Field(f => f.UUID).Editable(false);
                       m.Field(f => f.FechaEmision).DefaultValue(DateTime.Today);
                   })
                   .Events(events => events.Error("error_handler"))
                   .Sort(s => s.Add(f => f.FechaEmision).Descending())
                   .Read(read => read.Action("CFDISEgreso_Read", "SinLios"))
                   )
               )
               <script id="ConceptosEgresos_DetailTemplate" type="text/x-kendo-tmpl">
                   <h4>Detalle para CFDI \\##=UUID# </h4>
                   @(Html.Kendo().Grid<ConceptosViewModel>()
                       .Name("order_details#=UUID#")
                       .Columns(columns =>
                       {
                           columns.Command(command =>
                           {
                               command.Edit().UpdateText("Actualizar").Text("Editar");
                           }).Width(100);
                           columns.Bound(f => f.Id).Hidden(true);
                           columns.Bound(f => f.Cantidad).Width(50);
                           columns.Bound(f => f.ValorUnitario).Format("{0:c}").Width(80);
                           columns.Bound(f => f.Descripcion).Encoded(false)
                           .Title("Descripción").Filterable(false).Width(250);
                           columns.Bound(f => f.Importe).Format("{0:c}").Width(80);
                           columns.Bound(f => f.Deducible).ClientTemplate("<span> \\#= Deducible ? 'Si' : 'No' \\#</span>")
                           .Title("Deducible").Width(80);
                           columns.Bound(f => f.DeducibleAnual).ClientTemplate("<span> \\#= DeducibleAnual ? 'Si' : 'No' \\#</span>")
                           .Title("Deducible Anual").Width(100);
                           columns.Bound(f => f.MontoDeducible).Title("Monto Deducible").Format("{0:c}").Width(100);
                           columns.Bound(f => f.CatalogoCuentaId).ClientTemplate("\\#=CatalogoCuentas.Nombre\\#").Title("Catálogo de Cuentas")
                           .Filterable(false).Width(200).ClientFooterTemplate("Total Deducible:");
                           columns.Bound(f => f.CatalogoCuentas.Nombre);
                           //.Hidden(true);
                           columns.Template(f => new { })
                           .Title("Total Deducible")
                           .ClientTemplate("\\#=kendo.toString(GetOrderItemPrice(data), \"c\")\\#")
                           .ClientFooterTemplate("<span name='sum'></span>").Width(120);
                           columns.Bound(f => f.IVA16).ClientTemplate("<span> \\#= IVA16 ? 'Si' : 'No' \\#</span>")
                         .Filterable(false).Title("IVA 16%").Width(80);
                           columns.Bound(f => f.IVA0).ClientTemplate("<span> \\#= IVA0 ? 'Si' : 'No' \\#</span>")
                           .Filterable(false).Title("IVA 0%").Width(80);
                           columns.Bound(f => f.IVAExento).ClientTemplate("<span> \\#= IVAExento ? 'Si' : 'No' \\#</span>")
                           .Filterable(false).Title("Exento IVA").Width(80);
                           columns.Bound(f => f.VisiblePara).Width(80);
 
                       })
                       .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("ConceptosEditor"))
                       .Events(e =>
                       {
                           e.DataBound("onOrderDetailsEgresoDataBound");
                       })
                       .Selectable()
                       .Pageable(pageable => pageable.Refresh(true))
                       .Navigatable()
                       .Resizable(resize => resize.Columns(true))
                       .DataSource(dataSource => dataSource
                       .Ajax()
                       .Model(model =>
                       {
                           model.Id(concepto => concepto.Id);
                           model.Field(concepto => concepto.Id).Editable(false);
                           model.Field(concepto => concepto.Descripcion).Editable(false);
                           model.Field(concepto => concepto.Unidad).Editable(false);
                           model.Field(concepto => concepto.Cantidad).Editable(false);
                           model.Field(concepto => concepto.UUID).Editable(false);
                           model.Field(concepto => concepto.IVA16).DefaultValue(false);
                           model.Field(concepto => concepto.IVA0).DefaultValue(false);
                           model.Field(concepto => concepto.IVAExento).DefaultValue(false);
                           model.Field(concepto => concepto.Importe).Editable(true);
                           model.Field(concepto => concepto.ValorUnitario).Editable(false);
                           model.Field(concepto => concepto.CatalogoCuentaId).Editable(true);
                           model.Field(concepto => concepto.CatalogoCuentas).DefaultValue(ViewData["catalogos"] as CatalogoCuentasViewModel).Editable(true);
                           model.Field(concepto => concepto.Ano).Editable(true);
                           model.Field(concepto => concepto.Mes).Editable(true);
                           model.Field(concepto => concepto.VisiblePara).Editable(true);
                       })
                       .Events(events => events.Error("error_handler")
                       .Sync("sync_handler"))
                       .Read(read => read.Action("Conceptos_Read", "SinLios", new { UUID = "#=UUID#", Ano = "#=Ano#", Mes = "#=Mes#", VisiblePara = "#=RFCReceptor#" }))
                       .Update(update => update.Action("UpdateConcepto", "SinLios")))
                       .ToClientTemplate()
                   )
               </script>

And the code for populate the catalogo de cuentas:

public void PopulateCatalogoCuentas(string RFC)
{
  IOrderedEnumerable<CatalogoCuentasViewModel> catalogos = _context.CatalogoDeCuentasRFC(RFC)
               .Select(c => new CatalogoCuentasViewModel
               {
                   CatalogoCuentaId = c.CatalogoCuentaId,
                   Nombre = c.Nombre + " - " + c.CatalogoCuentaId
               }).ToList()
               .OrderBy(e => e.Nombre);
 
           bool existe = (from item in catalogos select item).Count() > 0;
 
           if (existe)
           {
               ViewData["catalogos"] = catalogos;
               ViewData["defaultCatalogo"] = catalogos.FirstOrDefault();
           }
           else
           {
               ViewData.Clear();
               IOrderedEnumerable<CatalogoCuentasViewModel> todoCatalogo = _catalogoCuentasRepository.FindAll()
               .Select(c => new CatalogoCuentasViewModel
               {
                   CatalogoCuentaId = c.CatalogoCuentaId,
                   Nombre = c.Nombre + " - " + c.CatalogoCuentaId
               })
               .OrderBy(e => e.Nombre);
 
               ViewData["catalogos"] = todoCatalogo;
               ViewData["defaultCatalogo"] = todoCatalogo.First();
           }
       }

 

 

3 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 16 Aug 2016, 11:31 AM
Hi Ross,

I have examined the code and it seems that you are using custom edit template for the Grid. Please check out the project linked below that illustrates how you can implement custom editor for the Grid widget. Try to use similar approach and see how it works for you.




Regards,
Viktor Tachev
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Ross
Top achievements
Rank 1
answered on 16 Aug 2016, 06:08 PM
Hi Viktor, the editor template is working and before I need to filter my catalogue by each person it was working correctly, since I implement the option that when a person is selected every catalogue in the combobox inside the ConceptosEgresos_DetailTemplate, needs to be updated it does not work the codebehind is executed correctly but the grid is not refreshed with the new values in the combobox
0
Viktor Tachev
Telerik team
answered on 17 Aug 2016, 11:15 AM
Hello Ross,

Would you send us a sample runnable project where the behavior you are seeing is replicated? This way we will be able to examine the behavior locally and look for its cause.  You can open a formal support ticket and send the project as attachment in zip format.

Regards,
Viktor Tachev
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Ross
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Ross
Top achievements
Rank 1
Share this question
or