Un foro de discusión para nuestra comunidad de hispano hablante
By andresoivan
#785241
Quisiera saber como podría pasar a un textbox el total por producto de una grilla . PM2.8

EJ.

myGrilla

cantidad| Producto
20 Gasolina
30 Diesel
40 Gasolina
120 Gasolina
25 Diesel


Textbox1
totalGasolina = 180

textbox2
totalDiesel = 55
By MickyRamirez
#785252
Hola andresoivan,

Te adjunto un ejemplo que nosotros tenemos para realizar este tipo de operaciones:

function showTotal() {
var price = parseFloat(getGridValueById("ProductsGrid", 1, "price"));
var tax = price * parseFloat(getGridValueById("ProductsGrid", 1, "taxRate"));
var total = price + tax;
G.alert("The total price is $" + total", "Total");
}
getGridField("ProductGrid", 1, "price").onchange = showTotal;

Te adjunto tambien el link donde se encuentran estos helpers en JS.

http://wiki.processmaker.com/index.php/ ... ById.28.29

Saludos.
By andresoivan
#785258
hola Micky Ramirez,

En realidad lo que necesito es agrupar los totales por producto en una grilla y desplegarlo en unos textbox que tengo en mi formulario. el código que tengo es el siguiente, pero solo me funciona el primer FOR que cumpla la condición, no ingresa al siguiente FOR.

Code: Select all
function calcDays() {
   var dStart, dEnd, daysDiff;
   var totalRows = Number_Rows_Grid("grilla_detalle", "peso_grilla");
   var granTotal = 0;
   var totPeso = 0;
   var totPeso2 = 0;
   var totPeso3 = 0;
  
   if (getField("fecha_notificacion").value != "" && getField("fecha_pago").value != "") {
      dStart = new Date(getField("fecha_notificacion").value);
      dEnd = new Date(getField("fecha_pago").value);
      daysDiff = Math.ceil((dEnd.getTime() - dStart.getTime()) / 86400000 );

      getField("dias").value = daysDiff ;
   }
  
   
   for (var i = 1;  i <= totalRows && getGridField("grilla_detalle", i, "contenido").value == "cargaGeneral"; i++) {
       totPeso += parseFloat(getGridField("grilla_detalle", i, "peso_grilla").value.replace(/\,/g, ''));   
     
       if  ((daysDiff > 1) && (totPeso  >0 && totPeso  < 100) && (getGridField("grilla_detalle", i, "contenido").value) == "cargaGeneral")  {
         getField("almacenaje").value =    (Math.round(totPeso * (daysDiff - 1) * 0.27)).toFixed(0).replace(/(\d)(?=(\d{3})+\.)/g, '$1,');
       }
   }
  
   for (var g = 1;  g <= totalRows && getGridField("grilla_detalle", g, "contenido").value == "frio"; g++ )  {
       totPeso2 += parseFloat(getGridField("grilla_detalle", g, "peso_grilla").value.replace(/\,/g, ''));
    
       if  ((daysDiff > 1) && (totPeso2  > 0) && (getGridField("grilla_detalle", g, "contenido").value) == "frio") {
           getField("almacenaje_cargaperecedera").value =    (Math.round(totPeso2 * (daysDiff - 1) * 0.33)).toFixed(0).replace(/(\d)(?=(\d{3})+\.)/g, '$1,');
           getField("entrada_fija_perecedera").value = (Math.round(29.00)).toFixed(0).replace(/(\d)(?=(\d{3})+\.)/g, '$1,');
       }
   }
}

getField("fecha_pago").onchange = calcDays;
getField("fecha_notificacion").onchange = calcDays;
calcDays();
#785261
hola andresoivan;

debes utilizar java script para poder hacer la sumatoria de rows diferentes en una grilla te dejo un ejemplo espero te ayude
Code: Select all
function calculateTotal() {
  var nRows = Number_Rows_Grid("Gridcombustible", "cantidad");
  var totalgas = 0;
  var totaldiesel = 0;
   
  for (var i = 1; i <= nRows; i++) 
    {
      
       if (getGridField("Gridcombustible", i, "producto").value == "gasolina")
          { 
           totalgas = totalgas + parseInt( getGridField("Gridcombustible", i, "cantidad").value);
           }                       
       else 
          {
           totaldiesel = totaldiesel + parseInt(getGridField("Gridcombustible", i, "cantidad").value);
          } 
      
      getField("gas").value = parseInt(totalgas);
      getField("diesel").value = parseInt(totaldiesel);
        
    }
};
document.getElementById("cantidades").onchange=calculateTotal; //execute when value in grid's HTML table changes
calculateTotal(); //execute when DynaForm loads
saludos!

If you're looking to save big on your next online […]

If you're looking to save big on your next online […]

If you're looking to save big on your next online […]

Use the latest Freecash referral code "FC2507[…]