Custom editor not called when template function is applided

3 posts, 0 answers
  1. Novak
    Novak avatar
    2 posts
    Member since:
    Apr 2016

    Posted 06 Oct Link to this post

    Hello,

    I noticed that custom editor is partially working, or I am doing something wrong.
    This example works, when template is actually referencing the model. So, initial value is setup from the template referencing the model, and edit is done by calling "CustomEditor" function where I have full flexibility for editing (kendoDatePicker, kendoTimePicker, or even create my own HTML and append it to container). Here is definition of grid column:
    gridColumns.push({
       title: fieldDefinition.Title,
       width: '100px',
       field: fieldDefinition.Name,
       template: "#=Fields[" + i + "].Value#",
       editor: CustomEditor });


    In addition I would like that my initial cells of grid looks a bit different, each cell have different behavior depending on model (enable/disable, color, background-color, ...).
    To achieve that, I wanted to use function call in template instead of referencing the model. So I defined the function that will accept the model and index of current item in my model, and will return apropriate HTML depending on the model;

    CreateTemplate(model, index){ .... }


    And setup call to this function within the template:

    gridColumns.push({
       title: fieldDefinition.Title,
       width: '100px',
       field: fieldDefinition.Name,
       template: "#= MyModule.createTemplate(data, " + i + ") #",
       editor: CustomEditor });

    Now, I have my template function getting called and initial cells are how I wanted them to be, but my CustomEditor is not called when I click on the cell, like it was called in the first example.

    It seems that even propagation is stopped, so when I click on input that is added through template, CustomEditor is not called, but if I click in tiny space between cell and input element (that is inside the same cell) then CustomEditor is called. 

    Am I doing something wrong or this is bug/limitation in Kendo?

    Regards,
    Nole

  2. Novak
    Novak avatar
    2 posts
    Member since:
    Apr 2016

    Posted 06 Oct in reply to Novak Link to this post

    I was able to find workaround, and I really hate workarounds.

    In my template where I create HTML and input element with all the properties that I need, I register onlick event handler that will trigger click event for the parent.

    Any real solution for this problem?

    Regards,

    Novak

     

  3. Stefan
    Admin
    Stefan avatar
    1137 posts

    Posted 10 Oct Link to this post

    Hello, Nole,

    Thank you for the provided information.

    Currently, the described result is expected as the custom input is stealing the focus and it is interfering with the expected event's propagation. In general, the template is used for presentation purpose and an input is not expected for presentation mode, as there is an edit mode which will render an editable input.

    Could you please share more details for the scenario in which an input is needed, in a read-only mode of the Grid cell, so we can discuss it and check if another approach can be applied.

    Regards,
    Stefan
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top