Set Textbox value in Editor Template from Javascript

2 posts, 1 answers
  1. Robert Madrian
    Robert Madrian avatar
    96 posts
    Member since:
    Apr 2003

    Posted 05 Aug Link to this post

    Hello,

    I have a grid with a  Editor Template with one TextBox and a Upload Control (see Code)

    in the Upload Control Client Event "Success" I want to set the filename to the TextBox Control - how to Access the TextBox Control in edit mode of the template from this Event?

    @model string
    @using Kendo.Mvc.UI
     
    @Html.TextBoxFor(model => model, new { @class = "k-textbox" })
    @(Html.Kendo()
                .Upload()
                .Multiple(false)
                .Messages(m => m.HeaderStatusUploaded("Erfolgreich"))
                .Messages(m => m.Select("Word Dokument hochladen..."))
                //.HtmlAttributes(new { accept = "application/pdf" })
                .Name("Wordvorlage1Upload")
                .Async(a => a
                .Save("Save", "Auszeichnungsart")
                .AutoUpload(true)
              )
             .Events(events => events
                  .Upload("onUpload")
                  .Success("onUploadSuccess")
              )
    )

    the Javascript Events

    function onUpload(e) {
            //var grid = $("#grid").data("kendoGrid");
            //grid.saveChanges();
            e.data = { Auszeichnungsart_ID: $("#Auszeichnungsart_ID").val() };
        }
     
        function onUploadSuccess(e) {
            alert(e.files[0].name);

        here I want to set the TextBox value of the edit template

            var grid = $("#grid").data("kendoGrid");
            grid.dataSource.read();
        }

  2. Answer
    Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 09 Aug Link to this post

    Hi Robert,

    You can check whether the e argument holds a reference to the Upload DOM element, for example e.sender. Then, you can use it to get the sibling textbox element.

    Regards,
    Eyup
    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
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top