Hi, I’m having problem with my work. It won’t display anything. Am i writing the code correctly?
Client Side
if (id=="bank"){
w3 = dhxWins.createWindow("w3", 30, 98, 1310, 521);
w3.setText("Bank Records");
//
var inner = w3.attachLayout("2U");
//
var toolbar1 = w3.attachToolbar();
toolbar1.setSkin("dhx_skyblue");
toolbar1.setIconSize(28);
toolbar1.setIconsPath("icons/");
toolbar1.loadStruct("data/dhxtoolbar_button3");
//
inner.cells("a").attachHTMLString("");
inner.cells("a").setWidth(350);
inner.cells("a").setText("");
inner.cells("a").hideHeader();
inner.cells("b").attachHTMLString("2U right");
var Grid1 = inner.cells("b").attachGrid();
inner.cells("b").hideHeader();
Grid1.setSkin("dhx_skyblue");
Grid1.setHeader(" Code,Branch Name,Account Title,Address,Manager Name,Account Number");
Grid1.setColumnIds("branch_id,bank_name,acct_number,address,manager_name,account_number");
Grid1.setInitWidths("70,230,250,*,*,*");
Grid1.setColAlign("left,left,left,left,left,left");
Grid1.setColTypes("ro,ro,ro,ro,ro,ro");
Grid1.setColSorting("str,str,str,str");
Grid1.attachHeader("#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter");
Grid1.init();
Grid1.load("database/bank.php");
contactForm = inner.cells("a").attachForm();
contactForm.loadStruct("data/bank.xml");
contactForm.bind(Grid1);
var dpg = new dataProcessor("database/bank.php");
dpg.init(Grid1);
dpg.attachEvent("onAfterUpdate", function(sid, action, tid, tag){
if (action == "inserted"){
Grid1.selectRowById(tid);
contactForm.setFocusOnFirstActive();
}
})
contactForm.attachEvent("onButtonClick", function(id){
contactForm.save();
});
toolbar1.attachEvent("onclick",function(id){
if(id=="add"){
dhtmlx.message({
text:"New Row Successfully Added!",
expire:4000,
type:"customCss" // 'customCss' - css class
});
var rowId=Grid1.uid();
var pos = Grid1.getRowsNum();
Grid1.addRow(rowId,["","",""],pos);
};
if(id=="delete"){
dhtmlx.alert({
type:"alert-error",
text:"Record Deleted Successfully",
title:"",
ok:""
});
var rowId = Grid1.getSelectedRowId();
var rowIndex = Grid1.getRowIndex(rowId);
if(rowId!=null){
Grid1.deleteRow(rowId);
if(rowIndex!=(Grid1.getRowsNum()-1)){
Grid1.selectRow(rowIndex+1,true);
}
else{
Grid1.selectRow(rowIndex-1,true)
}
}
}
});
Server Side - PHP Connector
<?php
require("../codebase/connector/grid_connector.php");
$res=mysql_connect("localhost","root","");
mysql_select_db("smct");
$conn = new GridConnector($res);
if ($conn->is_select_mode())
function myBranchData($data){
if ($data->getValue("branch_id") == 0)
$data->setValue("branch_id", "All");
$data->setValue("acct_number", $data->getValue("branch_id")." - ".$data->getValue("description"));
}
$conn->event->attach("beforeRender", "myBranchData");
$conn->render_sql("SELECT branches.branch_code, bank.*,
chart_of_accounts.account_number AS acct_number, chart_of_accounts.description FROM bank
LEFT JOIN branches ON bank.branch_id=branches.id
LEFT JOIN chart_of_accounts ON bank.gl_code_id=chart_of_accounts.id", "id", "branch_code,bank_name,acct_number,address,manager_name,account_number");
else
$conn->render_table("bank","id","branch_id,bank_name,contact_person,address,manager_name,account_number");
XML File for Bank
<?xml version="1.0"?>
<items>
<item type="settings" inputWidth="200" position="label-left" labelWidth="100"/>
<item type="label" label="Bank Records" offsetLeft="15"/>
<item type="input" label="Bank Code" name="branch_id" offsetLeft="15"/>
<item type="input" label="Branch Name" name="bank_name" offsetLeft="15"/>
<item type="input" label="Account Title " name="acct_number" offsetLeft="15"/>
<item type="input" label="Address" name="address" offsetLeft="15"/>
<item type="input" label="Manager" name="manager_name" offsetLeft="15"/>
<item type="input" label="Account No" name="account_number" offsetLeft="15"/>
<item type="button" value="Submit" offsetTop="30" offsetLeft="80"/>
</items>
Database.rar (554 KB)