Calling a text/x-kendo-template script type from a javascript function

5 posts, 1 answers
  1. Allan
    Allan avatar
    3 posts
    Member since:
    Jul 2017

    Posted 14 Jul Link to this post

    I have a custom button on scheduler's toolbar and on "onclick" event I'm calling function "openEditor()". Inside this function I want to call a `text/x-kendo-template` script type. How can I do this?

    My code right now:

    Custom button:

    schedulerToolbar.append(
    "<ul class='k-reset'>
       <li class='k-state-default'>
         <a role='button' href='#' class='k-link newMeetingButton' onclick='openEditor()'>
           Nova reserva
         </a>
       </li>
    </ul>"
    )

    Function openEditor():

    function openEditor() {
       *code to call customEditorTemplateBh script*
     }

    Template script:

    <script id="customEditorTemplateBh" type="text/x-kendo-template">
       *template code*
    </script>

     

  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    1268 posts

    Posted 17 Jul Link to this post

    Hi Allan,

    See the second example in this documentation article, which demonstrates how the template's content can be shown:
    //Get the external template definition using a jQuery selector
    var template = kendo.template($("#javascriptTemplate").html());
     
    //Create some dummy data
    var data = ["Todd.Holland", "Steve.Anglin", "Burke.Ballmer"];
     
    var result = template(data); //Execute the template
    $("#example").html(result); //Append the result


    Regards,
    Ivan Danchev
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Allan
    Allan avatar
    3 posts
    Member since:
    Jul 2017

    Posted 20 Jul in reply to Ivan Danchev Link to this post

    Hi Ivan.

    Thank you for your reply.

    I found a more simple solution for this case. The following code, on openEditor function, was enough:

    var scheduler = $("#scheduler-bh").data("kendoScheduler");
    scheduler.addEvent({ });
  4. Answer
    Ivan Danchev
    Admin
    Ivan Danchev avatar
    1268 posts

    Posted 24 Jul Link to this post

    Hi Allan,

    Indeed calling the Scheduler's addEvent method is the correct way to open the edit form programmatically, whereas the approach I mentioned in my previous reply can be used to show the content of a template in general, not the Scheduler's editor template specifically.

    Regards,
    Ivan Danchev
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. Allan
    Allan avatar
    3 posts
    Member since:
    Jul 2017

    Posted 24 Jul in reply to Ivan Danchev Link to this post

    Ivan, you are right.

    I forgot to mention that it's a Scheduler's editor template.

Back to Top