2

I have created a template in my grid:

template: '#if(IniReal != ""){# <div class="text-center">#= IniReal #</div> # } else {#<input class="fechaReal" />  #} #',

in this template a datepicker is created when the element of my arrangement comes empty

$(".fechaReal").kendoDatePicker({
                            format: "dd-MM-yyyy",                            
                            parseFormats: ["dd-MM-yyyy"],
                            change: vmSeg.Cambio,
                            close: vmSeg.Cerrar
                        });

the problem lies in the Close event after firing for the first time, the next time it fires, it does it twice, and so on, I just want the Close event triggered once and it does not fire repeatedly

This is my event Close

 vmSeg.Cerrar = function (e) {
                $("#ActiSeguimiento").on("focusout", ".k-datepicker", function (e) {
                    vmSeg.grid = $("#ActiSeguimiento").data("kendoGrid");
                    vmSeg.dataItem = vmSeg.grid.dataItem($(this).closest("tr"));                    
                    vmSeg.dataItem.IniReal = vmSeg.NuevaFecha;
                    return false;
                });
            }

and this is my event Change:

vmSeg.Cambio = function(e) {
                vmSeg.NuevaFecha = kendo.toString(kendo.parseDate(this.value()), "dd-MM-yyyy");

            }

What is wrong in my event Close?

Ulises_Tmtz
  • 55
  • 1
  • 8

1 Answers1

1

I have inspected the dojo that you provided and it seems like the issue is caused by declaration of the 'focusout' event that is hooked on every close not in the Kendo widget. When I removed the decalration of the 'focusout' event the scenario worked correctly. The close was triggered correctly at my side yet the 'focusout' was triggered many times. In such case I would recommend you to define as here it separately so that it triggers only once.

Plamen Zdravkov
  • 748
  • 5
  • 7
  • The reason of the 'focusout' is because i want recover the row and the selected value of the calendar addit to the row. And save data more later. – Ulises_Tmtz Feb 23 '18 at 16:20
  • Another way is to set the 'focusout' event only to the datepicker wrapper use the open event too and to remove it as for example in this [dojo](https://dojo.telerik.com/oHIGUV/2) – Plamen Zdravkov Feb 26 '18 at 12:33
  • Thanks!!!. Set the 'focusout' event in the wrapper solve my problem. Now i can continue with the flow – Ulises_Tmtz Feb 27 '18 at 18:50