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

[Solved] Viewmodel not updating inside window on save button click

1 Answer 149 Views
Window
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ryan
Top achievements
Rank 1
Ryan asked on 14 Jan 2013, 09:26 PM
I can't get my model to update the IncludeInFiling property inside my window. Please help!

function EditFileInclusionWindow(title, source) {
    var popup = $('#popupWindow1').data('tWindow');
    popup.title(title);
    popup.center().open();
}



Html.Telerik().Window()
                  .Name("popupWindow1")
                  .Modal(true)
                  .Width(400)
                  .Height(200)
                  .Buttons(buttons => buttons.Close())
                  .Draggable(false)
                  .Visible(false)
                  .Content(@<text>
                  <fieldset>
                      <div class="editor-label">
                          @Html.Label("Exclude the selected companies: ")
                      </div>
                      <br/>
                      <div class="editor-field">
                          @Html.RadioButtonFor(model => model.IncludeInFiling, false, new { id = "IncludeInFiling_false" })
                          <label for="IncludeInFiling_false">Yes</label>
                          @Html.RadioButtonFor(model => model.IncludeInFiling, true, new { id = "IncludeInFiling_true" })
                          <label for="IncludeInFiling_true">No</label>
                      </div>
                  <div>
                      <button type="submit" id="saveBtn1">Save</button>
                  </div>
                </fieldset>
          </text>)
          .Render();
$('#saveBtn1').click(function (e) {
    UpdateFileInclusionIndicator();
    $('#popupWindow1').closest('.t-window').data('tWindow').close();
     $("#CompanyListingGrid").data("tGrid").ajaxRequest();
});
function UpdateFileInclusionIndicator() {
    var jsonData = GetUserSelections();
    $.ajax({
        url: '@Url.Content("~/Generation/UpdateFileInclusionIndicator")',
        type: "POST",
        data: jsonData,
        contentType: "application/x-www-form-urlencoded",
        dataType: "html",
        success: function (json) {
            window.location = "ReadyQueueCompanyListing?collectorId=" + jsonData.SelectedCollector + "&filingYear=" + jsonData.SelectedFilingYear + "&filingMethod=" + jsonData.SelectedFilingMethod + "&serviceLevel=" + jsonData.SelectedServiceLevel;
        },
        error: function (xhr, ajaxOptions, thrownError) {
            alert(xhr.status);
            alert(thrownError);
        }
 
    });
}

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 17 Jan 2013, 05:54 PM
Hello Ryan,

When should the property be updated? From the code it seems that you are sending a JSON request to the server and then redirecting. Should the value be updated in the UpdateFileInclusionIndicator action? If yes, could you share the code for the method and the "GetUserSelections" function.

Kind regards,
Daniel
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
Tags
Window
Asked by
Ryan
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or