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

Editor Template with JavaScript/JQuery not working quite right

0 Answers 355 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 13 Jul 2013, 07:40 PM

I am using an editor template to provide custom behavior in my grid when a user edits a record.  The editor template .cshtml file is as follows:

@model string
@Html.TextBoxFor(s => s, new { id ="gradingSubItemGrade", @class="k-textbox" })
<script type="text/javascript">
    $(document).ready(function () {
        $('#gradingSubItemGrade').bind('keypress', function (e) {
            if (e.keyCode == 13) {
                var barcode = e.currentTarget.value;
                GetJSON('/API/CoinReferenceInformation/ByBarcode?barcode=' + barcode,
                    function (data) {
                        $('#gradingSubItemGrade').val(data.Grade + data.GradeNumber);
                    },
                    function () { });
            }
        });
    })
</script>

As you can probably see from the code sample, I am trying to send the text of the TextBox to a service (when [Enter] is pressed), then, upon receiving a response, override it with the results.

This almost works...the response comes back correctly, and the results are displayed in the TextBox.  However, what is saved is what the user entered, not what is returned by the service.

Are there additional steps I need to do to notify the grid that the text has changed?

*** EDIT ***

Sorry, I found my answer a few posts below here

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Steven
Top achievements
Rank 1
Share this question
or