Skip to main content
se añadieron 35 caracteres en el cuerpo
Origen Enlace
alanfcm
  • 20.9k
  • 11
  • 19
  • 35
d = {}
d.Factura = [{"Orden"       :1,
                        "Numero"      :1,
                        "Total"       :100,//Total
                        "Estatus"     :0},
            {"Orden"       :2,
                        "Numero"      :2,
                        "Total"       :200,//Total
                        "Estatus"     :6}]
des = [0,2,3,5]
                      

function format(d) {
    // `d` is the original data object for the row
   
      let tabla = `<table cellpadding="5" cellspacing="0" style="border-collapse: separate; border-spacing: 40px 5px;">
                    <thead>
                        <tr>                           
                            <th>
                                Total
                            </th>
                            <th style="display:none;">
                                Estatus
                            </th>                          
                        </tr>
                        </thead>
                        <tbody>`;
                            d.Factura.forEach(f => {
                                tabla += `<tr>                                                             
                                <td>${f.Total}</td>
                                               
                                <td><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#ModalCarga" onclick="Cargar('${f.Orden}' , '${f.Numero}')"`;
                                if (des.indexOf(f.Estatus) <> 3-1) {
                                  tabla += ` disabled `;
                                }
                                tabla += `>Cargar</button></td>
                                </tr>`;
                            });
                       tabla += '</tbody></table>';
                       return tabla;   
}
var main = $("#main");
main.append(format(d))
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="main"></div>
d = {}
d.Factura = [{"Orden"       :1,
                        "Numero"      :1,
                        "Total"       :100,//Total
                        "Estatus"     :0},
            {"Orden"       :2,
                        "Numero"      :2,
                        "Total"       :200,//Total
                        "Estatus"     :6}]
                      

function format(d) {
    // `d` is the original data object for the row
   
      let tabla = `<table cellpadding="5" cellspacing="0" style="border-collapse: separate; border-spacing: 40px 5px;">
                    <thead>
                        <tr>                           
                            <th>
                                Total
                            </th>
                            <th style="display:none;">
                                Estatus
                            </th>                          
                        </tr>
                        </thead>
                        <tbody>`;
                            d.Factura.forEach(f => {
                                tabla += `<tr>                                                             
                                <td>${f.Total}</td>
                                               
                                <td><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#ModalCarga" onclick="Cargar('${f.Orden}' , '${f.Numero}')"`;
                                if (f.Estatus < 3) {
                                  tabla += ` disabled `;
                                }
                                tabla += `>Cargar</button></td>
                                </tr>`;
                            });
                       tabla += '</tbody></table>';
                       return tabla;   
}
var main = $("#main");
main.append(format(d))
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="main"></div>
d = {}
d.Factura = [{"Orden"       :1,
                        "Numero"      :1,
                        "Total"       :100,//Total
                        "Estatus"     :0},
            {"Orden"       :2,
                        "Numero"      :2,
                        "Total"       :200,//Total
                        "Estatus"     :6}]
des = [0,2,3,5]
                      

function format(d) {
    // `d` is the original data object for the row
   
      let tabla = `<table cellpadding="5" cellspacing="0" style="border-collapse: separate; border-spacing: 40px 5px;">
                    <thead>
                        <tr>                           
                            <th>
                                Total
                            </th>
                            <th style="display:none;">
                                Estatus
                            </th>                          
                        </tr>
                        </thead>
                        <tbody>`;
                            d.Factura.forEach(f => {
                                tabla += `<tr>                                                             
                                <td>${f.Total}</td>
                                               
                                <td><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#ModalCarga" onclick="Cargar('${f.Orden}' , '${f.Numero}')"`;
                                if (des.indexOf(f.Estatus) > -1) {
                                  tabla += ` disabled `;
                                }
                                tabla += `>Cargar</button></td>
                                </tr>`;
                            });
                       tabla += '</tbody></table>';
                       return tabla;   
}
var main = $("#main");
main.append(format(d))
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="main"></div>
Origen Enlace
alanfcm
  • 20.9k
  • 11
  • 19
  • 35

No necesitas agregar el Estatus a la tabla, pero si lo necesitas para la condicional de habilitar o no el boton. Puedes hacerlo asi:

d = {}
d.Factura = [{"Orden"       :1,
                        "Numero"      :1,
                        "Total"       :100,//Total
                        "Estatus"     :0},
            {"Orden"       :2,
                        "Numero"      :2,
                        "Total"       :200,//Total
                        "Estatus"     :6}]
                      

function format(d) {
    // `d` is the original data object for the row
   
      let tabla = `<table cellpadding="5" cellspacing="0" style="border-collapse: separate; border-spacing: 40px 5px;">
                    <thead>
                        <tr>                           
                            <th>
                                Total
                            </th>
                            <th style="display:none;">
                                Estatus
                            </th>                          
                        </tr>
                        </thead>
                        <tbody>`;
                            d.Factura.forEach(f => {
                                tabla += `<tr>                                                             
                                <td>${f.Total}</td>
                                               
                                <td><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#ModalCarga" onclick="Cargar('${f.Orden}' , '${f.Numero}')"`;
                                if (f.Estatus < 3) {
                                  tabla += ` disabled `;
                                }
                                tabla += `>Cargar</button></td>
                                </tr>`;
                            });
                       tabla += '</tbody></table>';
                       return tabla;   
}
var main = $("#main");
main.append(format(d))
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="main"></div>