Html and Css back a row in the table

Asked

Viewed 244 times

-1

There’s a For that goes line by line a list. This list returns me input and output of a process. The problem is that it does not return in the same row because it is either input or output.

I would like to show in the middle column the process and in the corner columns the inputs and outputs.

Since it is inside a for, it always breaks a row for the next record. It would be possible to just move up the record one row from that column above?

See the image:

inserir a descrição da imagem aqui

HTML:

<table id="EntradaProcessoSaida" class="table">
                        <thead>
                            <tr>
                                <th>Entrada </th>
                                <th width="50%" colspan="2"><center>Processo</center></th>
                                <th>Saída</th>
                            </tr>
                        </thead>
                        <tbody>



                            @{
                                string acaoInicial = "";
                                string acaoFinal = "";
                                string tituloInicial = "";
                                string tituloFinal = "";

                                /* p.Acao = reader["ACAO"].ToString();
                                p.TituloAcao = reader["TituloAcao"].ToString();
                                p.IdAcao = (int)reader["Acao"];
                                p.TipoES = reader["TIPO"].ToString();
                                p.TituloES = reader["Titulo"].ToString();
                                p.CodigosES = reader["Codigo"].ToString();*/

                                for (int i = 0; i < ViewBag.listaTudo.Count; i++)
                                {
                                    acaoInicial = ViewBag.listaTudo[i].Acao;
                                    tituloInicial = ViewBag.listaTudo[i].TituloAcao;
                                    string concatenaEntrada = ViewBag.listaTudo[i].TituloES + " - " + ViewBag.listaTudo[i].CodigosES;


                                    concatenaEntrada = concatenaEntrada.Remove(concatenaEntrada.Length - 1);


                                    if (acaoInicial != acaoFinal)
                                    {
                                        <tr><td colspan="4"><hr /></td></tr>
                                    }
                             @*/*ENTRADA*/*@
                            <tr>
                                @if (ViewBag.listaTudo[i].TipoES == "entrada")
                                {

                                    <td>@concatenaEntrada</td>
                                }
                                else
                                {
                                    <td></td>
                                }


                                @*/*Processo*/*@

                                @if (acaoInicial != acaoFinal)
                                {
                                    <td><font size="14"><b>@ViewBag.listaTudo[i].Acao</b></font></td>
                                    <td>@ViewBag.listaTudo[i].TituloAcao</td>
                                }
                                else
                                {
                                    if (tituloInicial != tituloFinal)
                                    {
                                        <td></td>
                                        <td>@ViewBag.listaTudo[i].TituloAcao</td>
                                    }
                                    else
                                    {
                                        <td></td><td></td>
                                    }

                                }




                                @*/*Saída*/*@
                                @if (ViewBag.listaTudo[i].TipoES == "saida")
                                {
                                    <td>@concatenaEntrada</td>
                                }
                                else
                                {
                                    <td></td>
                                }


                                @{
                                    acaoFinal = ViewBag.listaTudo[i].Acao;
                                    tituloFinal = ViewBag.listaTudo[i].TituloAcao;
                                    cont++;
                                }

                            </tr>
                                }


                            }


                        </tbody>

                    </table>

css:

.relativeDireita {
    position: relative;
    /* left: 600px; */
    width: 200px;
    height: auto;
    /*border: solid #000000 1px;*/
}

Return from the list :

inserir a descrição da imagem aqui

SQL:

declare @processo int = 9
-- Lista ações do processo

SELECT 
    distinct
    CASE 
        when ga.Descricao ='ACTION' THEN 'A'
        when ga.Descricao ='PLAN'   THEN 'P'
        when ga.Descricao ='CHECK' THEN 'C'
        when ga.Descricao ='DO' THEN 'D'
    END ACAO
        , 
    pg.Titulo TituloAcao,
    pg.Id as  Acao,

    case
        when pga.Id_Acao = 1 then
            'entrada'
        when pga.Id_Acao = 2 then
            'saida'
    end TIPO,
    pga.Titulo,
     UPPER
             (
                    SUBSTRING
                           (
                                  ISNULL
                                        (
                                               STUFF
                                                      (
                                                             (
                                                               SELECT
                                                                   convert(varchar(10),c.Codigo) + ',' codigo
                                                               FROM
                                                                    Qualidade_Diagrama_Processo_Grupo_Acao a 
                                                                   join Qualidade_Diagrama_Acao_Entidade b on (b.Id_Proc_Grupo_Acao = a.Id)
                                                                   join Qualidade_Diagrama_Entidade c on (c.Id = b.Id_Entidade)
                                                               WHERE
                                                                          b.Id_Proc_Grupo_Acao = ae.Id_Proc_Grupo_Acao
                                                               FOR XML PATH(''), TYPE
                                                             ).value('.', 'NVARCHAR(MAX)') ,1,0,''
                                                      ),' '
                                        ),1,254
                           )
             ) as Codigo,
             ga.Codigo_Posicao
 FROM  
    Qualidade_Diagrama_Processo_Grupo pg
     JOIN  Qualidade_Diagrama_Processo p  on (p.Id = pg.Id_Processo)
     JOIN  Qualidade_Diagrama_Grupo_Acoes ga on (ga.Id = pg.Id_Grupo_Acoes)
     join setor s on (s.id = p.Setor)
     join Usuario_Interno u on (u.id = p.Usuario_Criacao)
     left Join Qualidade_Diagrama_Processo_Grupo_Acao pga on (pga.Id_Processo_Grupo = pg.Id)
     left join Qualidade_Diagrama_Acao_Entidade ae on (ae.Id_Proc_Grupo_Acao = pga.Id)
 WHERE 
    1=1 
    AND pga.Data_Exclusao is null
    and p.Id = @processo

    order by ga.Codigo_Posicao
  • You’d have to treat it on for but would still give a job, it would be better to generate a new list already right in the format you need and then generate html from it

  • @Ricardopunctual the problem is that the Query has been a lot of work. Ta huge and every time I touch it to list the output on the same line as the entries, I get wrong result.

  • I think you can do this easily on C# even, depending even on Linq, and let your View do the basics, just show

  • How do you know that the input and output are matching? has a field linking the two information that are on different lines?

  • Yes you do. By the Action Id of the process. I’m trying to bargain for what’s inside

  • the problem is not in the for yes in the data. You should have a list with Input/Process/Output in the same record, not in several. Show how you are assembling the list ViewBag.listaTudo.

  • @Rovannlinhalis I edited. I put in the question the SQL and its return

  • You need to do a query that returns: Titulo Entrada | Acao | Processo | Titulo Saida recommend to do the query first without grouping the ids, leave it for later, when the query is already returning the right data

Show 3 more comments

1 answer

1

You can group the data using Linq without having to change the query, for example:

var agrupado = from m in movimentos
                           group m by m.IdAcaoProcesso into g
                           select new
                           {
                               Id = g.Key,
                               Processo = g.FirstOrDefault().Processo,
                               Entrada = g.Any(x => x.TipoES == "Entrada") ? g.FirstOrDefault(x => x.TipoES == "Entrada").CodigoES : "",
                               Saida = g.Any(x => x.TipoES == "Saida") ? g.FirstOrDefault(x => x.TipoES == "Saida").CodigoES : ""
                           };

In this example, Agrouped the result of the query that is in a List in the variable moves, bringing input and output in single object.

See a functional example of dotnetfiddle: https://dotnetfiddle.net/6ihinZ

  • I’ll try . A question, use "grouped" in the controller with the list already filled or while filling in the model?

  • You can group in the Controller and already pass to the View the grouped list, ready to do only the for and assemble the table

  • It didn’t Certp. Damn it

  • Did you make a mistake? Can you share the code from Inq?

  • move pro chat that I explain to you and print if possible. Since thanks for the intention

  • https://chat.stackexchange.com/rooms/79805/c-agrupar-com-linq

Show 1 more comment

Browser other questions tagged

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