Good day everyone, I was really having a hard time finding a solution to my problem.
This is the scenario that i want to see. In the first picture the pattern of the grid is 1C which is on the “sales” and when i go to the “bank” the pattern should be 2U. The problem is that i used unload() to remove the first pattern which is “1C” to be able for me to put the new pattern which is the “2U”. In my case what i did is that i type the command layout.unload() and make another layout and named it layout2(). I wish u will get my point.
I’ll post my code below, i wanted a solution that i could call only the function of 1C. Or i don’t know how to explain because i’m not really a programmer. So pls help me.
[code]
SMCT Group of Companies html, body { width: 100%; height: 100%; margin: 0px; overflow: hidden; background-color:white; } <script type="text/javascript">
dhtmlxEvent(window,"load",function(){
var layout = new dhtmlXLayoutObject(document.body,"1C");
var a = layout.cells('a')
a.hideHeader();
var toolbar1 = layout.attachToolbar();
toolbar1.setIconSize(28);
toolbar1.setIconsPath("icons/");
toolbar1.loadStruct("data/dhxtoolbar_button2");
var menu_1 = layout.attachMenu();
menu_1.setSkin("dhx_skyblue");
menu_1.setIconsPath('icons/');
menu_1.loadStruct('data/dhxmenu.xml');
menu_1.attachEvent("onClick", function(id, zoneId, cas)
{
// Start of Sales onClick Event
if (id == “sales”){
{
var grid_1 = a.attachGrid();
grid_1.setSkin(“dhx_skyblue”);
a.showHeader();
a.setText(‘Sales’);
grid_1.setIconsPath(‘icons/’);
grid_1.setHeader([“Code”,“Product”]);
grid_1.setColTypes(“ro,ro”);
grid_1.setColSorting(‘str,str’);
grid_1.attachHeader(“#text_search,#text_search”);
grid_1.setInitWidths(‘,’);
grid_1.enableSmartRendering(true);
grid_1.load(‘database/categories.php’);
grid_1.init();
return 0;
}
toolbar1.attachEvent(“onClick”, function(id){
// Start of Saving Command Button
if (id==“save”){
var dpg = new dataProcessor(“database/categories.php”,“database/spareparts.php”);
dpg.init(grid_1);
dpg.attachEvent(“onAfterUpdate”, function(sid, action, tid, tag){
if (action == “inserted”){
grid_1.selectRowById(tid);
grid_1.setFocusOnFirstActive();
}
})
dhtmlx.message({
text:“Your data has already been saved!”,
expire:4000,
type:“customCss” // ‘customCss’ - css class
});
}
// End of Saving Command Button
// Start of Refresh Command Button
if (id==“reload”){
grid_1.updateFromXML(‘database/categories.php’);
}
// End of Refresh Command Button
});
}
// End of Sales onClick Event
// Start of Charge onClick Event
if (id == “charge”){
a.setText(‘Charge’);
var grid_2 = a.attachGrid();
grid_2.setSkin(“dhx_skyblue”);
grid_2.setIconsPath(‘icons/’);
grid_2.setHeader([“Barcode”,“Product Code”,“Description”,“Category”,“Subcategory”,“Brand”,“Model”,“Supplier”,“Date”]);
grid_2.setColTypes(“ro,ro,ro,ro,ro,ro,ro,ro,ro”);
grid_2.setColSorting(‘str,str,str,int,int,int,str,int,date’);
grid_2.attachHeader(“#text_search,#text_search,#text_search,#text_search,#text_search,#text_search,#text_search,#text_search,#text_search”);
grid_2.setInitWidths(‘,,,,,,,,*’);
grid_2.enableSmartRendering(true);
grid_2.load(‘database/spareparts.php’);
grid_2.init();
toolbar1.attachEvent("onClick", function(id){
// Start of Saving Command Button
if (id==“save”){
var dpg = new dataProcessor(“database/categories.php”,“database/spareparts.php”);
dpg.init(grid_2);
dpg.attachEvent(“onAfterUpdate”, function(sid, action, tid, tag){
if (action == “inserted”){
grid_2.selectRowById(tid);
grid_2.setFocusOnFirstActive();
}
})
dhtmlx.message({
text:“Your data has already been saved!”,
expire:4000,
type:“customCss” // ‘customCss’ - css class
});
}
// End of Saving Command Button
});
}
if (id==“bank”){
layout.unload();
var layout2 = new dhtmlXLayoutObject(document.body,"2U");
var b = layout2.cells('a')
b.hideHeader();
layout2.cells("a").setWidth(350);
var c = layout2.cells('b')
var toolbar2 = layout2.attachToolbar();
toolbar2.setIconSize(28);
toolbar2.setIconsPath("icons/");
toolbar2.loadStruct("data/dhxtoolbar_button2");
var menu_2 = layout2.attachMenu();
menu_2.setSkin("dhx_skyblue");
menu_2.setIconsPath('icons/');
menu_2.loadStruct('data/dhxmenu.xml');
//////////////////////////////////////////////////////////////////
// START OF THE MENU AND TOOLBAR
//////////////////////////////////////////////////////////////////
menu_2.attachEvent("onClick", function(id, zoneId, cas)
{
// Start of Sales onClick Event
if (id == “sales”){
{
layout2.unload();
var layout = new dhtmlXLayoutObject(document.body,“1C”);
var a = layout.cells(‘a’)
a.hideHeader();
var toolbar1 = layout.attachToolbar();
toolbar1.setIconSize(28);
toolbar1.setIconsPath(“icons/”);
toolbar1.loadStruct(“data/dhxtoolbar_button2”);
var menu_1 = layout.attachMenu();
menu_1.setSkin(“dhx_skyblue”);
menu_1.setIconsPath(‘icons/’);
menu_1.loadStruct(‘data/dhxmenu.xml’);
}
toolbar1.attachEvent(“onClick”, function(id){
// Start of Saving Command Button
if (id==“save”){
var dpg = new dataProcessor(“database/categories.php”,“database/spareparts.php”);
dpg.init(grid_1);
dpg.attachEvent(“onAfterUpdate”, function(sid, action, tid, tag){
if (action == “inserted”){
grid_1.selectRowById(tid);
grid_1.setFocusOnFirstActive();
}
})
dhtmlx.message({
text:“Your data has already been saved!”,
expire:4000,
type:“customCss” // ‘customCss’ - css class
});
}
// End of Saving Command Button
// Start of Refresh Command Button
if (id==“reload”){
grid_1.updateFromXML(‘database/categories.php’);
}
// End of Refresh Command Button
});
}
// End of Sales onClick Event
// Start of Charge onClick Event
if (id == “charge”){
a.setText(‘Charge’);
var grid_2 = a.attachGrid();
grid_2.setSkin(“dhx_skyblue”);
grid_2.setIconsPath(‘icons/’);
grid_2.setHeader([“Barcode”,“Product Code”,“Description”,“Category”,“Subcategory”,“Brand”,“Model”,“Supplier”,“Date”]);
grid_2.setColTypes(“ro,ro,ro,ro,ro,ro,ro,ro,ro”);
grid_2.setColSorting(‘str,str,str,int,int,int,str,int,date’);
grid_2.attachHeader(“#text_search,#text_search,#text_search,#text_search,#text_search,#text_search,#text_search,#text_search,#text_search”);
grid_2.setInitWidths(‘,,,,,,,,*’);
grid_2.enableSmartRendering(true);
grid_2.load(‘database/spareparts.php’);
grid_2.init();
toolbar1.attachEvent("onClick", function(id){
// Start of Saving Command Button
if (id==“save”){
var dpg = new dataProcessor(“database/categories.php”,“database/spareparts.php”);
dpg.init(grid_2);
dpg.attachEvent(“onAfterUpdate”, function(sid, action, tid, tag){
if (action == “inserted”){
grid_2.selectRowById(tid);
grid_2.setFocusOnFirstActive();
}
})
dhtmlx.message({
text:“Your data has already been saved!”,
expire:4000,
type:“customCss” // ‘customCss’ - css class
});
}
// End of Saving Command Button
});
}
})
//////////////////////////////////////////////////////////////////
// END OF THE MENU AND TOOLBAR
//////////////////////////////////////////////////////////////////
}
// End of Charge onClick Event
if (cas.ctrl == true) {
// open in a new tab
} else {
// open on the same page
}
});
})
</script>
[/code]