Telerik Forums
UI for ASP.NET MVC Forum
3 answers
73 views
I have a grid that uses Batch mode.  On the Save event  I need to obtain a reference to a dropdownlist (not the cell, but the widget) in the 4th cell of this grid.  How do you do this?
Greg
Top achievements
Rank 1
 answered on 22 Aug 2016
2 answers
274 views

I have a map that a user will utilize in order to mark their position. I use geolocation and Bing layer to give them a good start. I want them to click on the map, have it recenter to the point they click, remove the existing marker, then create a new one where the map is centered.

 

function onClick(e) {
            var resultArray = e.location.toString().split(',');
            
            $('#map').data("kendoMap").center([parseFloat(resultArray[0]), parseFloat(resultArray[1])]);
            $('#map').data("kendoMap").markers.clear();
            $('#map').data("kendoMap").markers.add([parseFloat(resultArray[0]), parseFloat(resultArray[1])]);
        }

The function above centers the map, removes the previous marker, and does not give an error on the ADD.  However, the new marker doesn't show up.

Help please.

Patrick | Technical Support Engineer, Senior
Telerik team
 answered on 19 Aug 2016
1 answer
76 views

Hi,

 I have a grid with checkboxes in the last column.

I want the user to select the hours in the grid he wants to move.
After selecting all the hours he needs I want him to press a button and there should be an action against all selected lines.

 

See alse the attached screenshot.

 

How can I do this?

Eyup
Telerik team
 answered on 19 Aug 2016
7 answers
1.1K+ views

Hi,

ClientTemplate for the ID value is not working for me. Still outputs the ID to Service field. What am I missing?

Main .cshtml:

Main .cshtml:
@(Html.Kendo().Grid(Model.ManualJobItems)
      .Name("gridBreakDowns")
      .Columns(columns =>
      {
          columns.Bound(p => p.ItemID).Hidden(true);
          columns.Bound(p => p.ParentID).Hidden(true);
          columns.Bound(p => p.FileName).Title("File").Width(130);
          columns.Bound(p => p.ServiceName).Title("Service").Width(200).ClientTemplate("#=ServiceName#").EditorTemplateName("ServiceId");
          columns.Bound(p => p.Country).Title("Country").Width(300).EditorTemplateName("CountryId");
          columns.Bound(p => p.Format).Title("Format").Width(200);
          columns.Bound(p => p.Method).Title("Service Level").Width(200);
          columns.Bound(p => p.Quantity).Title("Quantity").Width(100);
          columns.Bound(p => p.ItemWeight).Title("Item Weight").Width(200);
          columns.Bound(p => p.TotalWeight).Title("Total Weight").Width(200);
          columns.Bound(p => p.DespatchStatusString).Title("Status");
          columns.Command(command => { command.Destroy(); }).Width(100);
      })
      //.Events(events => events.Edit("onGridEdit").Save("onGridSave"))
      .Editable(editable => editable
          .Mode(GridEditMode.InCell))
              .ToolBar(toolBar =>
              {
                  toolBar.Custom().Text("Create").Name("addNewRow").Url("#").HtmlAttributes(new {onclick = "addNewCustomRow()" });
                  toolBar.Save();
              })
            .Events(e => e.DataBound("onRowBound"))
            .DataSource(dataSource => dataSource
          .Ajax()
          .Batch(true)
          .Events(events => events.Error("onerror_handler"))
          .Create(create => create.Action("UpdateManualJobItem", "ManualJob"))
          .Read(read => read.Action("ReadManualJobItem", "ManualJob", new { jid = Model.JobID }))
          .Update(update => update.Action("UpdateManualJobItem", "ManualJob"))
          .Destroy(destroy => destroy.Action("DestroyManualJobItem", "ManualJob"))
          .Model(model =>
          {
              model.Id(p => p.ItemID);
          })
))
 
ServiceId.cshtml:
@(Html.Kendo().DropDownListFor(m => m)
    .OptionLabel("Select Service...")
    .DataTextField("ServiceName")
    .DataValueField("ServiceID")
    .DataSource(source =>
    {
        source.Read(read =>
        {
            read.Action("GetCurrentNormalServices", "System");
        });
        source.ServerFiltering(true);
    }))
     
CountryId.cshtml:
@(Html.Kendo().DropDownListFor(m => m)
    .OptionLabel("Select Country...")
    .DataTextField("CountryName")
    .DataValueField("CountryID")
    .DataSource(source =>
    {
        source.Read(read =>
        {
            read.Action("GetServiceCountries", "System").Data("filterCountries");
        });
        source.ServerFiltering(true);
    })
    .CascadeFrom("ServiceID"))
     
SystemController:
public JsonResult GetCurrentNormalServices()
{
    var services = _db.Services.GetAllCurrentNormalServices().Select(x => new { x.ServiceID, x.ServiceName }).ToList();
    return Json(services, JsonRequestBehavior.AllowGet);
}

neet-o
Top achievements
Rank 1
 answered on 19 Aug 2016
2 answers
168 views

I have a five digit postal code and want to exclude zero as first character and only allow numeric values.

Html.Kendo().MaskedTextBoxFor(a => a.Postnummer)
                    .Rules(rules => { rules.Add('0', "/[1-9]/"); })
                    .Mask("00000"))

 

not working, cant type in 0 at all.

Reine
Top achievements
Rank 1
 answered on 19 Aug 2016
1 answer
215 views

Hi there,

I want a chart similiar to the one attached with this thread. Currently I am using scatter chart for my purpose but it would be great if I could get it colored like the attached screenshot.

Any help would be greatly appreciated.

 

 

Patrick | Technical Support Engineer, Senior
Telerik team
 answered on 18 Aug 2016
17 answers
465 views

Hi guys is it possible to add upload control inside subgrid with clientdetailtemplate?because after adding the control the main grid it nolonger loads the data, please see below the code 

<div  style="clear:both;  position:relative; padding-top: 10px">
 
@(Html.Kendo().Grid<KendoUIApp1_Test.Models.IncidentsViewModel>()
              .Name("grid")
          
 
              .Columns(colums =>
              {
                   * http://www.telerik.com/blogs/kendo-ui-r1-2016-webinar-wrapup
                   */
                  colums.Bound(p => p.DepartmentID).Hidden(true);
                  colums.Bound(p => p.SiteAuditID).Hidden(true);
                  colums.Bound(p => p.QuestionID).Hidden(true);
 
                  colums.Bound(p => p.StatusName).Title("Status").Filterable(false).ClientTemplate(
                                                                                                   "# if (StatusID === 1 ) { #" +
                                                                                                     "<span class='CBdrawingstatusGreen'>#:StatusName#</span>" +
                                                                                                  "# } else if (StatusID === 2 ) { #" +
                                                                                                      "<span class='CBdrawingstatusYellow'>#:StatusName#</span>" +
                                                                                                  "# } else { #" +
                                                                                                      "<span class='CBdrawingstatusred'>#:StatusName#</span>" +
                                                                                                  "# } #"
 
                                                                                                );
                  colums.Bound(p => p.ReferenceNo).Title("ReferenceNo").Filterable(true);
                  colums.Bound(p => p.IncidentDate).Title("IncidentDate").ClientTemplate("#= kendo.format('{0:MM/dd/yyyy HH:mm:ss}',kendo.parseDate(IncidentDate)) #"); //.Filterable(model => model.UI("IncidentDateFilter"));
                  colums.Bound(p => p.AccountName).Title("Airport").Filterable(false).Width(200);
                  colums.Bound(p => p.SiteName).Title("Site").Filterable(false);
                  colums.Bound(p => p.Department1).Title("Department").Filterable(false);
                  colums.Bound(p => p.Description).Title("Description").Filterable(false);
                  colums.Bound(p => p.Comments).Title("Comments").Filterable(false);
                  colums.Bound(p => p.ContactName).Title("CurrentAssignedContact").Filterable(false).Width(200);
                  colums.Bound(p => p.FirstName).Title("CurrentAssignedUser").Filterable(false);
                  colums.Bound(p => p.IncidentID).ClientTemplate("<a class='k-button' href='" + Url.Action("GetPDF", "Home") + "?IncidentID=#= IncidentID #'" + "> <span span class='k-icon k-i-pdf''></span>Get Incident Pdf</a>").Title("Download PDF").Filterable(false);
                
                  colums.Command(cmd =>
                  {
                      cmd.Edit();
                      //cmd.Custom("Upload").Click("onCustomCommandClick");
                  });
 
              })
              .ClientDetailTemplateId("client-template")
          .Filterable(filterable => filterable
            .Extra(true)
            .Operators(operators => operators
                .ForString(str => str.Clear()
                    .StartsWith("Starts with")
                    .IsEqualTo("Is equal to")
                    .IsNotEqualTo("Is not equal to")
 
                ))
            )
 
    .HtmlAttributes(new { style = "height:550px;" })
    .DataSource(datasource => datasource
    .Ajax() //Configure the grid data source
     
    .Events(Eevents => Eevents.RequestEnd("OnChangeRefresh"))
    .Model(model =>
    {
        model.Id(m => m.IncidentID);
 
 
    })
    .Read(read =>
    {
        read.Action("GetIncidents", "Home").Data("IncidentsFilter");
    })// set the action method which will return the data in json format
 
    .Update(update => update.Action("Incidents_Update", "Home"))
    )
 
    .Navigatable()
    .Groupable()
    .Pageable()
    .Reorderable(reorder => reorder.Columns(true))
    .Sortable()
    .Scrollable()
        .Events(events =>
        {
            events.Save("onIncidentUserAssign");
            // events.Save("onStatusChange");
 
        })
 
            .Events(eEvents => eEvents.Edit("disableOnEdit"))
            .Events(x => x.DataBound("onDataBound"))
        //.Events(events =>
        //{
        //  events.Save("onStatusChange");
        //   // events.Save("onStatusChange");
 
        //})
 
 
    .Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("Incidents")
                                               .Window(w => w.Animation(true)
                                               .Scrollable(false)
                                               .Name("editWindow")))
     
 
        )
    
    </div>
 
<script id="client-template" type="text/x-kendo-template">
    @(Html.Kendo().Grid<KendoUIApp1_Test.Models.AuditPicIncidentModel>()
        .Name("Grid_#=SiteAuditID#")
          .ToolBar(toolbar => toolbar.Template(
     
        @<text>
            @(Html.Kendo().Upload()
                  .Name("files")
                  .Async(a => a.Save("Save", "Home"))
                  .Events(e => e.Success("onUploadSuccess"))
                  .ShowFileList(false) // Hide the file list as we're displaying uploaded files in the Grid
            )
          </text>
    ))
        .Columns(columns =>
                            {
                                columns.Bound(b => b.FileName).Title("File Name");
                                columns.Bound(b => b.PictureCaption).Title("Picture Caption").HtmlAttributes(new { style = "overflow: hidden;text-overflow: ellipsis;white-space:nowrap;" }).EditorTemplateName("ConfigurationSettingItemEditor");
                          
                                columns.Command(command => command.Destroy()).Width(100);
                                 
                            }
                )
        .Sortable()
        .Pageable(c => c.PageSizes(new int[] { 10, 20, 50, 100 }))
        .Scrollable()
        .HtmlAttributes(new { style = "height:430px;" })
        .DataSource(datasource => datasource
                    .Ajax()
                      .Model(model =>
                            {
                                model.Id(q => q.AuditResultPictureID);
                                //model.Field(q => q.KeyValue).Editable(true);
                                //model.Field(q => q.Enabled).DefaultValue(true);
  
                            })
                    .PageSize(10)
                    .ServerOperation(true)
                    .Read(read => read.Action("ConfigurationItem_Read", "Home", new { SiteAuditID = "#=SiteAuditID#", QuestionID = "#=QuestionID#" }))
                    .Destroy(update => update.Action("FilesDestriy", "Home"))
                     )
                      
                      
        .ToClientTemplate()
          
          
  
  
    )
 
   
  
</script>

Marc Plaxton-Harrison
Top achievements
Rank 1
 answered on 18 Aug 2016
1 answer
245 views

Hi i have an task scheduller

And would like to get ID of current task using  CustomEditorTemplate 

@Model.TaskID is always equals to 0

.Editable(editable =>
                  {
                      editable.TemplateName("CustomEditorTemplate");
                  })

 @(Html.Kendo().Scheduler<TaskViewModel>()
                  .Name("schedule")
                  .Date(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day))
                  .StartTime(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 9, 00, 00))
                  .EndTime(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 18, 00, 00))
                  .HtmlAttributes(new {@class = "ra-section"})
                 
                  .Views(views =>
                  {
                      views.DayView(dayView => dayView.Selected(true));
                      views.WeekView();
                      views.MonthView();
                      views.AgendaView();
                  })
                  .Editable(editable =>
                  {
                      editable.TemplateName("CustomEditorTemplate");
                  })
                  .Timezone("Etc/UTC")

                  .DataSource(dataSource => dataSource
                      .Model(m =>
                      {
                          m.Id(f => f.TaskID);
                          m.Field(f => f.Title);
                          m.Field(f => f.Start);
                          m.Field(f => f.End);
                          m.Field(f => f.Description);
                          m.Field(f => f.RecurrenceID);
                          m.Field(f => f.RecurrenceRule);
                          m.Field(f => f.RecurrenceException);
                          m.Field(f => f.IsAllDay);
                          m.Field(f => f.StartTimezone);
                          m.Field(f => f.EndTimezone);
                      })
                      .Events(e => e.Error("error_handler"))
                      .Read("ChargerTous", "TaskScheduler")
                      .Create("Ajouter", "TaskScheduler")
                      .Update("Modifier", "TaskScheduler")
                      .Destroy("Supprimer", "TaskScheduler")
                  )
                  )

And I have a custom editor template

@model Gloe.Web.Website.ViewModel.TaskViewModel
@{
    ViewContext.FormContext = new FormContext();
}

<div data-container-for="grid" class="k-edit-field">

        @(Html.Kendo().Grid<Gloe.Web.Website.ViewModel.TaskScheduler.PrelevementViewModel>()
    .Name("grid")
    .Columns(columns =>
    {

        columns.Bound(p => p.NomPrelevement).ClientTemplate("\\#= productDetails(data) \\#")
          .ClientFooterTemplate("count : \\#=count \\#")
            .ClientGroupFooterTemplate("count : \\#=count \\# ");
        columns.Bound(p => p.ValeurPrelevement).Width(120)
        .ClientFooterTemplate("Sum: \\#=sum\\# ")
            .ClientGroupFooterTemplate("Sum: \\#=sum\\# ");

        columns.Command(command => { command.Edit(); command.Destroy(); }).Width(250);

    })

    .ToolBar(toolbar => toolbar.Create())
    .Editable(editable => editable.Mode(GridEditMode.InLine))
    .Events(events => events.Change("onChange").DataBound("onDataBound").DataBinding("onDataBinding"))

    .DataSource(dataSource => dataSource
        .Ajax()
         .Aggregates(aggregates =>
         {
             aggregates.Add(p => p.NomPrelevement).Count();
             aggregates.Add(p => p.ValeurPrelevement).Sum();
         })
        .PageSize(20)

        .Model(model =>
        {
            model.Id(l => l.IdPrelevement);
            model.Field(field => field.IdPrelevement).Editable(false);
            model.Field(field => field.NomPrelevement).Editable(false);
            model.Field(field => field.ValeurPrelevement);
        })
        .Create(update => update.Action("EditingInline_Create", "RapportAnalyse").Data("additionalInfo"))
        .Read(read => read.Action("EditingInline_Read", "RapportAnalyse").Data("GetTaskID"))
        .Update(update => update.Action("EditingInline_Update", "RapportAnalyse"))
        .Destroy(update => update.Action("EditingInline_Destroy", "RapportAnalyse"))
    )
        )
    </div>
</div>

@{
    ViewContext.FormContext = null;
}

Vladimir Iliev
Telerik team
 answered on 18 Aug 2016
3 answers
169 views

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();
           }
       }

 

 

Viktor Tachev
Telerik team
 answered on 17 Aug 2016
3 answers
127 views

hi , I have a  pretty simple requirement for doing that I have written the following code.

 

grid is in paymentviewgrid cshtml which is being called in the index page, below

 

     function BuGridSaveChange(e)
    {   
        if (manualList.length > 0)
        {
            var isRecordExist = false;
            var totalRecords = manualList;
            for (var i = 0; i <= totalRecords.length - 1; i++)
            {
                if (manualList[i].PoId == e.model.PoId && manualList[i].RCUId == e.model.RCUId && manualList[i].MrrId == e.model.MrrId
                    && manualList[i].BU_Id == e.model.BU_Id
                    && manualList[i].REUId == e.model.REUId)
                {
                    manualList[i].ManualAmountPaid = e.model.ManualAmountPaid;
                    isRecordExist = true;
                }
            }
            if (isRecordExist == false)
            {
                var singleSrObj = new Object();
                singleSrObj.PoId = e.model.PoId;
                singleSrObj.REUId = e.model.REUId;
                singleSrObj.RCUId = e.model.RCUId;
                singleSrObj.MrrId = e.model.MrrId;
                singleSrObj.ManualAmountPaid = e.model.ManualAmountPaid;
                singleSrObj.BU_Id = e.model.BU_Id;
                manualList.push(singleSrObj);
            }
        }
        else
        {
            var singleNewSrObj = new Object();
            singleNewSrObj.PoId = e.model.PoId;
            singleNewSrObj.REUId = e.model.REUId;
            singleNewSrObj.RCUId = e.model.RCUId;
            singleNewSrObj.MrrId = e.model.MrrId;
            singleNewSrObj.ManualAmountPaid = e.model.ManualAmountPaid;
            singleNewSrObj.BU_Id = e.model.BU_Id;
            manualList.push(singleNewSrObj);
        }
    }

    function RequestEnd(e)
    {         
     if (e.response.Errors == null )      
        {
            if ((e.type === "update" )&& e.response.Data.length > 0)
            {
                if (manualList.length > 0)
                {
     
                    var isAmountEntered = false;
     
                    for (var i = 0; i <= manualList.length - 1; i++)
                    {
                        if (manualList[i].ManualAmountPaid != null && manualList[i].ManualAmountPaid >= 0)
                        {
                            isAmountEntered = true;
                        }
                        if (manualList[i].PoId == e.response.Data[0].PoId && manualList[i].RCUId == e.response.Data[0].RCUId && manualList[i].MrrId == e.response.Data[0].MrrId
                            && manualList[i].BU_Id == e.response.Data[0].BU_Id
                            && manualList[i].REUId == e.response.Data[0].REUId)
                        {
                            manualList[i].ManualAmountPaid  = e.response.Data[0].ManualAmountPaid;
                            document.getElementById("approvePaymentButton").disabled = true;
                            document.getElementById("poSummaryPaymentButton").disabled = true;
                        }
                    }
                    if (isAmountEntered == true)
                    {
                        document.getElementById("recreatePaymentButton").disabled = false;
                    }
                    else
                    {
                        document.getElementById("recreatePaymentButton").disabled = true;
                        document.getElementById("approvePaymentButton").disabled = false;
                        document.getElementById("poSummaryPaymentButton").disabled = false;
                    } 
                }
            }
           
        }
        else if (e.response.Errors != null && e.type === "update")
        {       
         document.getElementById("recreatePaymentButton").disabled = true;
        }
    }

 

 

the issue is while coding this

I received e.type== "update " and in update function I have written some other businesslogic

and after testing and implementation with no code changes , I started receiving e.type== "create" where I cannot see update atall.

due to this I cannot call the logic that was in update function from controller.

 

could you please help on this

 

 

Konstantin Dikov
Telerik team
 answered on 17 Aug 2016
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
Upload
ComboBox
MultiSelect
ListView
Window
TabStrip
Menu
Installer and VS Extensions
Spreadsheet
AutoComplete
TreeList
Gantt
PanelBar
NumericTextBox
Filter
ToolTip
Map
Diagram
Button
PivotGrid
Form
ListBox
Splitter
Application
FileManager
Sortable
Calendar
View
MaskedTextBox
PDFViewer
TextBox
Toolbar
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
ListView (Mobile)
Pager
Accessibility
ColorPicker
DateRangePicker
Wizard
Security
Styling
Chat
MediaPlayer
TileLayout
DateInput
Drawer
SplitView
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Template
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Rating
ScrollView
ButtonGroup
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Licensing
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
DropDownButton
AIPrompt
PropertyGrid
ActionSheet (Mobile)
BulletGraph
Button (Mobile)
Collapsible
Loader
CircularGauge
SkeletonContainer
Popover
HeatMap
Avatar
ColorGradient
CircularProgressBar
SplitButton
StackLayout
TimeDurationPicker
Chip
ChipList
DockManager
ToggleButton
Sankey
OTPInput
ChartWizard
SpeechToTextButton
InlineAIPrompt
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
AICodingAssistant
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?