Adding rows to a grid wiht loaded data
Hi Everyone, I'm working with the last trial version and I've got some problems. I'm developing a site where customer can order some products from a company. Customers are able to full-fill orders, then modify them and finally they have to close each of them. I have no problem with the first and the third step, but I do have some with the modification step. It is a page with a grid and some textfield outside the grid. The grid brings the data that was uploaded when the customer order it in the first step. My problem relies on how to continue adding lines to the grid and in some cases how to modify lines that are in the grid. These are the scripts that I wrote:
obj.onCellEditEnded = function(text, col, row){
var xcanti, xprecio, xbonif, xsubto, ximporte, xpiva, xpint, xim
if (col == 2) {
xcanti = obj.getCellValue(2,row);
xprecio = obj.getCellValue(3,row);
xbonif = 100 - ( 100 * (( 100 - obj.getCellValue(4,row)) / 100 ));
obj.setCellText(this.getCellFormat(4, row).dataToText(xbonif), 4,row);
xpiva = obj.getCellValue(5,row);
ximporte = xprecio * xcanti - (xprecio * xcanti * xbonif / 100);
obj.setCellText(this.getCellFormat(6, row).dataToText(ximporte), 6,row);
xim = ximporte * xpiva / 100;
obj.setCellText(this.getCellFormat(7, row).dataToText(xim), 7,row);
RefTotal();
} else {
obj.setCellText(this.getCellFormat(0, row).dataToText(obj.getCellValue(0,row)),0,row)
obj.setCellText(this.getCellFormat(1, row).dataToText(obj.getCellValue(1,row)),1,row)
obj.setCellText(this.getCellFormat(3, row).dataToText(obj.getCellValue(3,row)),3,row)
obj.setCellText(this.getCellFormat(4, row).dataToText(obj.getCellValue(4,row)),4,row)
obj.setCellText(this.getCellFormat(5, row).dataToText(0),7,row)
obj.setCellText(this.getCellFormat(6, row).dataToText(obj.getCellValue(6,row)),6,row)
obj.setCellText(this.getCellFormat(7, row).dataToText(obj.getCellValue(7,row)),7,row)
RefTotal();
}
Reload();
}
obj.onRowAdded = function(row){
var xLinea;
xLinea = CheckArti(document.getElementById("txtcodarti").value);
// alert("Línea: " + xLinea);
if (xLinea == -1) {
maxi = row
fila = row + 1;
window.status = "Fila nº: " + fila;
// a[row] = row;
obj.setCellText(this.getCellFormat(0, row).dataToText(document.getElementById("txtcodarti").value),0,row)
obj.setCellText(this.getCellFormat(1, row).dataToText(document.getElementById("txtdetalle").value),1,row)
obj.setCellText(this.getCellFormat(2, row).dataToText(document.getElementById("txtcanti").value),2,row)
obj.setCellText(this.getCellFormat(3, row).dataToText(document.getElementById("txtprecio").value),3,row)
obj.setCellText(this.getCellFormat(4, row).dataToText(0),4,row)
obj.setCellText(this.getCellFormat(5, row).dataToText(document.getElementById("txtiva").value),5,row)
xcanti = obj.getCellValue(2,row);
xprecio = obj.getCellValue(3,row);
xbonif = 100 - ( 100 * (( 100 - obj.getCellValue(4,row)) / 100 ) ) ;
obj.setCellText(this.getCellFormat(4, row).dataToText(xbonif), 4,row);
xpiva = obj.getCellValue(5,row);
ximporte = xprecio * xcanti - (xprecio * xcanti * xbonif / 100);
obj.setCellText(this.getCellFormat(6, row).dataToText(ximporte), 6,row);
xim = ximporte * xpiva / 100;
obj.setCellText(this.getCellFormat(7, row).dataToText(xim), 7,row);
RefTotal();
Reload();
document.getElementById("textfield85").value = "";
document.getElementById("txtcanti").value = "";
document.getElementById("txtcodarti").value = "";
document.getElementById("txtdetalle").value = "";
document.getElementById("txtprecio").value = "";
document.getElementById("txtiva").value = "";
} else {
xcanti = obj.getCellValue(2,xLinea) + (txtcanti.value * 1.00);
obj.setCellText(this.getCellFormat(2, xLinea).dataToText(xcanti),2,xLinea)
xprecio = obj.getCellValue(3,xLinea);
xbonif = 100 - ( 100 * (( 100 - obj.getCellValue(4,xLinea)) / 100 ) ) ;
obj.setCellText(this.getCellFormat(4, row).dataToText(xbonif), 4,xLinea);
xpiva = obj.getCellValue(5,xLinea);
ximporte = xprecio * xcanti - (xprecio * xcanti * xbonif / 100);
obj.setCellText(this.getCellFormat(6, xLinea).dataToText(ximporte), 6,xLinea);
xim = ximporte * xpiva / 100;
obj.setCellText(this.getCellFormat(7, xLinea).dataToText(xim), 7,xLinea);
RefTotal();
document.getElementById("textfield85").value = "";
document.getElementById("txtcanti").value = "";
document.getElementById("txtcodarti").value = "";
document.getElementById("txtdetalle").value = "";
document.getElementById("txtprecio").value = "";
document.getElementById("txtiva").value = "";
obj.deleteRow(maxi + 1);
}
}
This two scripts work when the orders are load, but they dont when orders are modified.
Here is the site if you want the whole picture... you could log-in with the user: D10050; pass: research
http://estudiosya.dnsalias.com/
To load an order, click "Cargue su pedido".
To load producst, use the search icon that says "Busque su producto".
You can search easy on Rubro "Anedra".
To modify orders, click "Pedidos cargados".
There you have the modifying icon.
I know that you have no need to see the whole site, but I think that if you see it, you'll understand what I'm trying to achieve. The Site is still been developed... Any kinds of criticism are welcome... I hope you could help me. The scripts are opened... you could see them all and if they are useful, you are free to copy them.
Sorry for my English...
obj.onCellEditEnded = function(text, col, row){
var xcanti, xprecio, xbonif, xsubto, ximporte, xpiva, xpint, xim
if (col == 2) {
xcanti = obj.getCellValue(2,row);
xprecio = obj.getCellValue(3,row);
xbonif = 100 - ( 100 * (( 100 - obj.getCellValue(4,row)) / 100 ));
obj.setCellText(this.getCellFormat(4, row).dataToText(xbonif), 4,row);
xpiva = obj.getCellValue(5,row);
ximporte = xprecio * xcanti - (xprecio * xcanti * xbonif / 100);
obj.setCellText(this.getCellFormat(6, row).dataToText(ximporte), 6,row);
xim = ximporte * xpiva / 100;
obj.setCellText(this.getCellFormat(7, row).dataToText(xim), 7,row);
RefTotal();
} else {
obj.setCellText(this.getCellFormat(0, row).dataToText(obj.getCellValue(0,row)),0,row)
obj.setCellText(this.getCellFormat(1, row).dataToText(obj.getCellValue(1,row)),1,row)
obj.setCellText(this.getCellFormat(3, row).dataToText(obj.getCellValue(3,row)),3,row)
obj.setCellText(this.getCellFormat(4, row).dataToText(obj.getCellValue(4,row)),4,row)
obj.setCellText(this.getCellFormat(5, row).dataToText(0),7,row)
obj.setCellText(this.getCellFormat(6, row).dataToText(obj.getCellValue(6,row)),6,row)
obj.setCellText(this.getCellFormat(7, row).dataToText(obj.getCellValue(7,row)),7,row)
RefTotal();
}
Reload();
}
obj.onRowAdded = function(row){
var xLinea;
xLinea = CheckArti(document.getElementById("txtcodarti").value);
// alert("Línea: " + xLinea);
if (xLinea == -1) {
maxi = row
fila = row + 1;
window.status = "Fila nº: " + fila;
// a[row] = row;
obj.setCellText(this.getCellFormat(0, row).dataToText(document.getElementById("txtcodarti").value),0,row)
obj.setCellText(this.getCellFormat(1, row).dataToText(document.getElementById("txtdetalle").value),1,row)
obj.setCellText(this.getCellFormat(2, row).dataToText(document.getElementById("txtcanti").value),2,row)
obj.setCellText(this.getCellFormat(3, row).dataToText(document.getElementById("txtprecio").value),3,row)
obj.setCellText(this.getCellFormat(4, row).dataToText(0),4,row)
obj.setCellText(this.getCellFormat(5, row).dataToText(document.getElementById("txtiva").value),5,row)
xcanti = obj.getCellValue(2,row);
xprecio = obj.getCellValue(3,row);
xbonif = 100 - ( 100 * (( 100 - obj.getCellValue(4,row)) / 100 ) ) ;
obj.setCellText(this.getCellFormat(4, row).dataToText(xbonif), 4,row);
xpiva = obj.getCellValue(5,row);
ximporte = xprecio * xcanti - (xprecio * xcanti * xbonif / 100);
obj.setCellText(this.getCellFormat(6, row).dataToText(ximporte), 6,row);
xim = ximporte * xpiva / 100;
obj.setCellText(this.getCellFormat(7, row).dataToText(xim), 7,row);
RefTotal();
Reload();
document.getElementById("textfield85").value = "";
document.getElementById("txtcanti").value = "";
document.getElementById("txtcodarti").value = "";
document.getElementById("txtdetalle").value = "";
document.getElementById("txtprecio").value = "";
document.getElementById("txtiva").value = "";
} else {
xcanti = obj.getCellValue(2,xLinea) + (txtcanti.value * 1.00);
obj.setCellText(this.getCellFormat(2, xLinea).dataToText(xcanti),2,xLinea)
xprecio = obj.getCellValue(3,xLinea);
xbonif = 100 - ( 100 * (( 100 - obj.getCellValue(4,xLinea)) / 100 ) ) ;
obj.setCellText(this.getCellFormat(4, row).dataToText(xbonif), 4,xLinea);
xpiva = obj.getCellValue(5,xLinea);
ximporte = xprecio * xcanti - (xprecio * xcanti * xbonif / 100);
obj.setCellText(this.getCellFormat(6, xLinea).dataToText(ximporte), 6,xLinea);
xim = ximporte * xpiva / 100;
obj.setCellText(this.getCellFormat(7, xLinea).dataToText(xim), 7,xLinea);
RefTotal();
document.getElementById("textfield85").value = "";
document.getElementById("txtcanti").value = "";
document.getElementById("txtcodarti").value = "";
document.getElementById("txtdetalle").value = "";
document.getElementById("txtprecio").value = "";
document.getElementById("txtiva").value = "";
obj.deleteRow(maxi + 1);
}
}
This two scripts work when the orders are load, but they dont when orders are modified.
Here is the site if you want the whole picture... you could log-in with the user: D10050; pass: research
http://estudiosya.dnsalias.com/
To load an order, click "Cargue su pedido".
To load producst, use the search icon that says "Busque su producto".
You can search easy on Rubro "Anedra".
To modify orders, click "Pedidos cargados".
There you have the modifying icon.
I know that you have no need to see the whole site, but I think that if you see it, you'll understand what I'm trying to achieve. The Site is still been developed... Any kinds of criticism are welcome... I hope you could help me. The scripts are opened... you could see them all and if they are useful, you are free to copy them.
Sorry for my English...
Marcos A. Guardia
August 11,