Im trying to init multiple grids to get some information from then close the grids. I dont see an event that I can use the grid.destructor(); on and if I use it at the bottom of my code it does not allow the extrapolation of data. Can you please point me in the right direction. I will post the code here maybe it will help.
Thanks
function doInitGrid()
{
catgrid = new dhtmlXGridObject('grid');
catgrid.setImagePath("dhtmlx/dhtmlxgrid/codebase/imgs/");
catgrid.setHeader("Name");
catgrid.setInitWidths("*");
catgrid.setColAlign("left");
catgrid.setSkin("light");
catgrid.setColumnIds("Name");
//catgrid.load("php/connector_cat.php");
catgrid.load("php/connector_cat.php", function() {
var catrows = catgrid.getRowsNum();
switch (catrows)
{
case 0:
document.getElementById("categorylabel").innerHTML="<center>There are 0 Categories</center>";
break;
case 1:
document.getElementById("categorylabel").innerHTML="<center>There is 1 Category</center>";
break;
default:
document.getElementById("categorylabel").innerHTML="<center>There are "+ catrows +" Categories</center>";
break;
}
});
catgrid.init();
locgrid = new dhtmlXGridObject('grid1');
locgrid.setImagePath("dhtmlx/dhtmlxgrid/codebase/imgs/");
locgrid.setHeader("Name");
locgrid.setInitWidths("*");
locgrid.setColAlign("left");
locgrid.setSkin("light");
locgrid.setColumnIds("Name");
// locgrid.load(“php/connector_loc.php”);
locgrid.load(“php/connector_loc.php”, function() {
var locrows = locgrid.getRowsNum();
switch (locrows)
{
case 0:
document.getElementById("locationlabel").innerHTML="<center>There are 0 locations</center>";
break;
case 1:
document.getElementById("locationlabel").innerHTML="<center>There is 1 location</center>";
break;
default:
document.getElementById("locationlabel").innerHTML="<center>There are "+ locrows +" locations</center>";
break;
}
});
locgrid.init();
typegrid = new dhtmlXGridObject('grid2');
typegrid.setImagePath("dhtmlx/dhtmlxgrid/codebase/imgs/");
typegrid.setHeader("Name");
typegrid.setInitWidths("*");
typegrid.setColAlign("left");
typegrid.setSkin("light");
typegrid.setColumnIds("Name");
// typegrid.load(“php/connector_type.php”);
typegrid.load(“php/connector_type.php”, function() {
var typerows = typegrid.getRowsNum();
switch (typerows)
{
case 0:
document.getElementById("typelabel").innerHTML="<center>There are 0 types</center>";
break;
case 1:
document.getElementById("typelabel").innerHTML="<center>There is 1 type</center>";
break;
default:
document.getElementById("typelabel").innerHTML="<center>There are "+ typerows +" types</center>";
break;
}
});
typegrid.init();
Itemgrid = new dhtmlXGridObject('grid3');
Itemgrid.setImagePath("dhtmlx/dhtmlxgrid/codebase/imgs/");
Itemgrid.setHeader("Name,Category,Itemtype,Description,Account,Active,Notes,Qtyonhand,Reorder,BUnit,SUnit,Price,Vendor,Date,CustID,Perishable");
Itemgrid.setInitWidths("*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*");
Itemgrid.setColAlign("left,left,left,left,left,left,left,left,left,left,left,left,left,left,left,left");
Itemgrid.setSkin("light");
Itemgrid.setColumnIds("Name,Category,Itemtype,Description,Account,Active,Notes,Qtyonhand,Reorder,BUnit,SUnit,Price,Vendor,Date,CustID,Perishable");
//Itemgrid.load("php/connector_Item.php");
Itemgrid.load("php/connector_Item.php", function() {
var a = 0;
var b = 0;
var irows = Itemgrid.getRowsNum();
switch (irows)
{
case 0:
document.getElementById("itemlabel").innerHTML="<center>There are 0 items</center>";
break;
case 1:
document.getElementById("itemlabel").innerHTML="<center>There is 1 item</center>";
break;
default:
document.getElementById("itemlabel").innerHTML="<center>There are "+ irows +" items</center>";
break;
}
while (a < irows)
{
Itemgrid.selectRow(a);
var selectedItem = Itemgrid.getSelectedRowId();
var Qty = Itemgrid.cells(selectedItem,7).getValue();
var Reord = Itemgrid.cells(selectedItem,8).getValue();
Qty = (Qty == "")? 0 : parseInt(Qty);
Reord = (Reord == "") ? 0 : parseInt(Reord);
var ttl = (Qty - Reord);
if (ttl <= 0)
{
b++;
}
a++;
}
switch (b)
{
case 0:
document.getElementById("itemreordlabel").innerHTML="<center>Re-Order 0 Items</center>";
break;
case 1:
document.getElementById("itemreordlabel").innerHTML="<center>Re-Order 1 Item</center>";
break;
default:
document.getElementById("itemreordlabel").innerHTML="<center>Re-Order "+ b +" items</center>";
break;
}
});
Itemgrid.init();
Vendgrid = new dhtmlXGridObject('grid4');
Vendgrid.setImagePath("dhtmlx/dhtmlxgrid/codebase/imgs/");
Vendgrid.setHeader("Name,Street,City,State,Zip,Contact,Account,Phone,Fax,Cell,Email");
Vendgrid.setInitWidths("*,*,*,*,*,*,*,*,*,*,*");
Vendgrid.setColAlign("left,left,left,left,left,left,left,left,left,left,left,left,left");
Vendgrid.setSkin("light");
Vendgrid.setColumnIds("Name,Street,City,State,ZipCode,Contact,AccountNumber,Phone,FaxNumber,CellNumber,Email");
//Vendgrid.load("php/connector_Vendor.php");
Vendgrid.load("php/connector_Vendor.php", function() {
var vrows = Vendgrid.getRowsNum();
switch (vrows)
{
case 0:
document.getElementById("vendorlabel").innerHTML="<center>There are 0 vendors</center>";
break;
case 1:
document.getElementById("vendorlabel").innerHTML="<center>There is 1 vendor</center>";
break;
default:
document.getElementById("vendorlabel").innerHTML="<center>There are "+ vrows +" vendors</center>";
break;
}
});
Vendgrid.init();
}