This is a migrated thread and some comments may be shown as answers.

Set Textbox value in Editor Template from Javascript

1 Answer 265 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
Robert Madrian asked on 05 Aug 2016, 12:03 PM

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

1 Answer, 1 is accepted

Sort by
0
Accepted
Eyup
Telerik team
answered on 09 Aug 2016, 11:00 AM
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
Tags
Grid
Asked by
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
Answers by
Eyup
Telerik team
Share this question
or