Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

295
Vistas
How to convert datatable rows to array?

I have to convert this rows to array per column in selected rows, i used C# MVC.

This is the view before and after click :

Selecting rows after click the button

here's the code :

@if (Model != null)
    {

        <table id="tablePenerima" class="table table-striped table-bordered animate__animated animate__fadeInRight" cellpadding="0" cellspacing="0">
            <thead>
                <tr>

                    @foreach (DataColumn col in Model.Tables[0].Columns)
                    {

                        <th align="center">@col.ColumnName</th>
                    }
                </tr>
            </thead>
            <tbody>
                @foreach (DataRow row in Model.Tables[0].Rows)
                {
                    <tr>

                        @foreach (DataColumn col in Model.Tables[0].Columns)
                        {
                            <td align="center">@row[col.ColumnName]</td>
                        }

                    </tr>
                }
            </tbody>
        </table>
    }
    else
    {
        <p style="color:red;"> Mohon upload file dahulu </p>
    }

    <div class="form-group">
        <button type="button" name="Blast" id="btnBlast" class="btn btn-lg btn-success"><span><i class="fas fa-bolt"> &nbsp; </i></span>BLAST</button>
    </div>

and the JS :

$(document).ready(function () {
        var table = $('#tablePenerima').DataTable({
            dom: 'Bfrtip',
            buttons: [

                'selectAll',
                'selectNone',

            ],
            select: true
        });

        $('#tablePenerima tbody').on('click', 'tr', function () {
            $(this).toggleClass('selected');
        });
        $('#btnBlast').click(function () {
            var rowdata = table.rows('.selected').data().toArray();
            var msg = '';
            for (var i = 0; i < rowdata.length; i++) {
                msg += rowdata[i]+ '\n'
            }
            alert(msg);
        })

    });

That's all. I want to change the output to be [array0] [array1] [array2] [array4] by per column because i want to use them in futher validation and method inside FOR condition in JS. Thank you :)

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda