For many days I've been trying unsuccessfully to implement Modal dialog editing in a flexigrid.
I started with a very simple example:
I expanded this example a lot, but I hit a road block and I don't know how to achieve desired functionality.
I implemented the following jquery function:
function RunModalDialog(title, url) { $("#sform").dialog({ autoOpen: false, show: "blind", closeOnEscape: true, resizable: true, width: 1200, height: 750, minHeight: 600, minWidth:950 }); if (title) $("#sform").dialog("option", "title", title); if (url) $("#sform").load(url).dialog("open"); else $("#sform").dialog("open");
And I am calling it from Add button (without url) and from the Edit button (with a url).
It works OK for the Add (although I haven't yet implemented actual save and grid refresh), but I can not make it work on Edit.
Here is my main view code
@model CardNumbers.Objects.Client
@{
ViewBag.Title = "Clients";
}
@section scripts {
<script src="@Url.Content("~/Scripts/Clients.js")" type="text/javascript" ></script>
}
<form id="frmClientsSearch">
<label for="clientNo">Client No: </label>
<input type="number" name="searchClientNo" class="numericOnly" /><br />
<label for="clientName">Client Name: </label>
<input type="text" size="25" value="Please enter the search value" class="SelectOnEntry"
name="searchClientName" />
<input type="button" id="btnClientsSearch" value="Find / Refresh" />
</form>
<div style="padding-left: 150px; padding-top: 50px; padding-bottom: 50px;" id="ClientsResults">
<table id="flexClients" style="display: none">
</table>
</div>
<div id="editor" style ="visibility :hidden ">
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "sform", title = "Client Info" }))
{
@Html.Partial("_ClientForm", Model)
}
</div>
And the Edit method of the client controller returns a view which is
@model CardNumbers.Objects.Client @{ ViewBag.Title = "Edit Client"; Layout = "~/Views/Shared/_PopupLayout.cshtml"; } @Html.Partial("_ClientForm", Model) @section Scripts { @Scripts.Render("~/bundles/jqueryval") }
I originally had the BeginForm inside the _ClientForm and I could see the form, but the x (close) and Resize didn't work. I now tried moving the line that starts the form outside, but now the behavior is even worse.
Can you tell me how this is supposed to work?