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

[Solved] Submit in Windows

0 Answers 27 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.
Rodrigo
Top achievements
Rank 1
Rodrigo asked on 17 Aug 2012, 10:56 AM
Hi I have a screen with a grid, where clicking a button opens a Window with information to update. How do I close that window when you upgrade? and also like to know how do I get it not to close. Currently it redirects to an action, but do not want this behavior.

Window
<script type="text/javascript">
    function AbrirConfiguracao(medicoId) {


        var url = '@Url.Action("ConfiguracaoAgenda", "Agenda", new { medicoId = "-1" })';
        url = url.replace("-1", medicoId);


        var windowElement = $.telerik.window.create({
            title: "<img alt='icon' class='t-image' src='/Content/Images/Icons/config1.png'>Configurações de Agenda",
            html: "<strong>Carregando configurações...</strong>",
            contentUrl: url,
            modal: true,
            resizable: false,
            draggable: true,
            scrollable: false,
            width: 630,
            height: 250,
            onClose: function (e) {
                e.preventDefault();
                windowElement.data('tWindow').destroy();
            },
            onRefresh: function (e) {
                windowElement.data('tWindow').center();
            },
            onSuccess: function (e) {
                windowElement.data('tWindow').close();
            }
        });


        windowElement.attr('id', 'configWindow');
        windowElement.data('tWindow').center().open();
    }


</script>


@using (Ajax.BeginForm(new AjaxOptions {UpdateTargetId = "configWindow" }))
{
    <table width="100%">
        <tr>
            <td align="left">
                <div>
                    @{ Html.Telerik().TabStrip()
                    .Name("TabStrip")
                     .BindTo(Model,
                        (tab, config) =>
                        {
                            tab.Text = config.DiaAtendimentoDescricao;
                            tab.ContentUrl = "ConfiguracaoAgendaDia/" + config.MedicoId + "?medicoId=" + config.MedicoId + "&diaSemana=" + Convert.ToInt32(config.DiaSemana);
                        })
                        .SelectedIndex(0)
                    .Render();
                   }
                </div>
            </td>
        </tr>
    </table>


    <table width="100%">
        <tr>
            <td align="center">
                <table>
                    <tr>
                        <td align="left">
                            @Html.ValidationSummary(false, "Corrija os erros e tente novamente")
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>

Controller
 public ActionResult ConfiguracaoAgenda(int medicoId)
        {
            ViewData.Model = AgendaFlow.Instance.ObterConfiguracoes(medicoId);
            return View();
        }


        public ActionResult ConfiguracaoAgendaDia(int medicoId, int diaSemana)
        {
            return PartialView(AgendaFlow.Instance.ObterConfiguracao(medicoId, diaSemana));
        }


        [HttpPost]
        public ActionResult ConfiguracaoAgendaDia(AgendaConfiguracao model)
        {
            if (ModelState.IsValid)
            {
                AgendaFlow.Instance.Update<AgendaConfiguracao>(model);
                TempData["Message"] = string.Format("Os dados foram salvos com sucesso.", "");
                return View(AgendaFlow.Instance.ObterConfiguracoes(model.MedicoId));
            }
            return PartialView(AgendaFlow.Instance.ObterConfiguracoes(model.MedicoId));
        }

View in TabStrip
@using (Html.BeginForm("ConfiguracaoAgendaDia", "Agenda", new { id = Model.AgendaConfiguracaoId }, FormMethod.Post))
{
    @Html.HiddenFor(m => m.AgendaConfiguracaoId)
     @Html.HiddenFor(m => m.MedicoId)
     @Html.HiddenFor(m => m.DiaSemana)
    <table width="100%">
        <tr>
            <td align="left">
                <div>
                    <table style="width: 100%; margin-top: 5px; border-top: 1px solid #A4ABB2; border-left: 1px solid #A4ABB2;
                        border-right: 1px solid #A4ABB2;" cellpadding="2" cellspacing="2">
                        <tr>
                            <td class="t-header" style="padding-left: 10px;">
                                @Html.Label("Atendimento")
                            </td>
                            <td class="dtvAlternatingRow" style="padding-left: 10px;">
                                <table>
                                    <tr>
                                        <td>
                                            @Html.Telerik().TimePickerFor(m => m.InicioAtendimento).Interval(1)
                                            @Html.ValidationMessageFor(m => m.InicioAtendimento, "*", new { title = "O início do atendimento é obrigatório." })
                                        </td>
                                        <td>
                                            à
                                        </td>
                                        <td>
                                            @Html.Telerik().TimePickerFor(m => m.TerminoAtendimento).Interval(1)
                                            @Html.ValidationMessageFor(m => m.TerminoAtendimento, "*", new { title = "O término do atendimento é obrigatório." })
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td class="t-header" style="padding-left: 10px;">
                                @Html.Label("Intervalo")
                            </td>
                            <td class="dtvAlternatingRow" style="padding-left: 10px;">
                                <table>
                                    <tr>
                                        <td>
                                            @Html.Telerik().TimePickerFor(m => m.InicioIntervalo).Interval(1)
                                            @Html.ValidationMessageFor(m => m.InicioIntervalo, "*", new { title = "O início do intervalo é obrigatório." })
                                        </td>
                                        <td>
                                            à
                                        </td>
                                        <td>
                                            @Html.Telerik().TimePickerFor(m => m.TerminoIntervalo).Interval(1)
                                            @Html.ValidationMessageFor(m => m.TerminoIntervalo, "*", new { title = "O término do intervalo é obrigatório." })
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td class="t-header" style="padding-left: 10px;">
                                @Html.Label("Intervalo entre consultas")
                            </td>
                            <td class="dtvAlternatingRow" style="padding-left: 10px;">
                                @Html.Telerik().IntegerTextBoxFor(m => m.IntervaloConsulta).MinValue(5).EmptyMessage("").InputHtmlAttributes(new { style = "width:60px" })
                                @Html.ValidationMessageFor(m => m.IntervaloConsulta, "*", new { title = "O intervalo entre as consultas é obrigatório." })
                            </td>
                        </tr>
                        <tr>
                            <td class="t-grid-pager t-grid-bottom" style="padding-top: 10px; padding-bottom: 10px;
                                border-top: 1px solid #A4ABB2" colspan="2">
                                <input type="submit" class="t-button" value="Salvar" />
                                <input type="button" class="t-button" value="Cancelar" onclick="closeWindow()" />
                            </td>
                        </tr>
                        <tr><td>@Html.ActionLink("Inserir", "InserirConfiguracao", "Agenda")</td></tr>
                    </table>
                </div>
            </td>
        </tr>
    </table>
    <table width="100%">
        <tr>
            <td align="center">
                <table>
                    <tr>
                        <td align="left">
                            @Html.ValidationSummary(false, "Corrija os erros e tente novamente")
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>

Tags
Window
Asked by
Rodrigo
Top achievements
Rank 1
Share this question
or