Display Null Variables in a Modal

Asked

Viewed 22 times

0

Guys I’m having the following problem.

I had to create an audit page of my system, where it displays the edits that were made in a certain form.

When a form is first filled in, it shows all the form variables, as you can see in the picture below.

inserir a descrição da imagem aqui

when the same form is edited, it displays the following screen.

inserir a descrição da imagem aqui

As you can see, on this second screen, it does not display all variables.

and my problem is this, I need that on this second screen, it exits all variables.

this modal is displaying only the variables that have been edited, I need it to display everything, even if there is no data in the field as shown in the photo above.

my JS

$(document).ready(function () {
    $('[name="btn_detalhes"]').click(function () {
        var altaUtiId = $(this).attr('id');
        var patientId = $(this).attr('data-content');
        $.ajax({
            method: 'POST',
            url: '/Formulario/AltaUTI/VerificaDiff',
            data: { 'PatientId': patientId, 'AltaUtiId': altaUtiId },
            success: function (response) {
                var t1 = response[0];
                var t2 = response[1];
                var registro = response[2];
                if (t1.length > 0 || t2.length > 0) {
                    $('#msgLoading').fadeIn(0);
                    $('.modal.Detalhes').modal({
                        closable: false,
                        blurring: true,
                    }).modal('show');
                    for (var i = 0; i < t1.length; i++) {
                        $('#trInser1').append('<p> ' + t1[i] + ' </p>');
                        if (t2.length > 0) {
                            $('#tdInser2').append('<p> ' + t2[i] + ' </p>');
                            $('#tdInser2').removeClass('display-none');
                            $('#colAtual').removeClass('display-none');
                            $('#colAtual').fadeIn();
                            $('#tdInser2').fadeIn();
                        }
                        else {
                            if (registro.length > 0)
                                $('#colAlterado').text('Usuário alterado');
                            else
                                $('#colAlterado').text('Usuário atual');

                            $('#tdInser2').addClass('display-none');
                            $('#colAtual').addClass('display-none');
                        }

                    }
                    $('#msgLoading').fadeOut(0);
                } else {
                    notif({
                        'type': 'error',
                        'msg': 'Não foi encontrado modificações no formulário!',
                        'position': 'center'
                    });
                }
            },
            error: function (response) {
                notif({
                    'type': 'error',
                    'msg': 'Erro na resposta do servidor!',
                    'position': 'center'
                });
            }
        })
    });

    $('.btn_ok').click(function () {
        $("p").remove();
        $("#colAtual").css({ display: "none" });
        $("#tdInser2").css({ display: "none" });
        $('.modal.Detalhes').modal('hide');
    });
});

my controller

[HttpPost]
        public ActionResult VerificaDiff(int AltaUtiId, int PatientId)
        {
            DataSet query = _altaUtiService.RetornaFormulario(AltaUtiId, PatientId);
            DataSet query2 = _altaUtiService.RetornaFormulario2(AltaUtiId, PatientId);
            DataSet query3 = _altaUtiService.RetornaQuantidadeRegistro(PatientId);
            List<string> list = new List<string>();
            List<string> list2 = new List<string>();
            List<string> Result = new List<string>();
            List<string> Result2 = new List<string>();
            List<string> Registro = new List<string>();
            int j = 0;
            foreach (DataRow dr in query.Tables[0].Rows)
            {
                if (query2.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dr2 in query2.Tables[0].Rows)
                    {
                        foreach (var item in dr2.ItemArray.ToArray())
                        {
                            list.Add(item.ToString());
                            j = j + 1;
                        }
                        foreach (var item in dr.ItemArray.ToArray())
                        {
                            list2.Add(item.ToString());
                        }
                        for (int i = 0; i < j; i++)
                        {
                            if (list[i] != list2[i])
                            {
                                Result.Add(queryAuditoriaAlta[i] + ": " + list[i].ToString());
                                Result2.Add(queryAuditoriaAlta[i] + ": " + list2[i].ToString());
                            }
                        }
                    }
                }
                else
                {
                    foreach (var item in dr.ItemArray.ToArray())
                    {
                        list.Add(item.ToString());
                        Result.Add(queryAuditoriaAlta[j] + ": " + list[j].ToString());
                        j = j + 1;

                        if (query3.Tables[0].Rows.Count > 1 && Registro.Count < 1)
                            Registro.Add("Sim");
                    }
                }
            }
            var resultado = new[] { Result, Result2, Registro };

            return Json(resultado, JsonRequestBehavior.AllowGet);
        }
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.