I am currently helping my company to investigate the feasibility of using dhtmlx in our project.
I am doing a testing to send back DHTMLX Form data to server side. We have used attachForm() to attach a DHTMLX Form object to DHTMLX Layout. We can load a hardcode JSON datasource successfully. However, when I trigger form_2.send(…), I observe from firebug that request is sent to server side (Server can received the request) but no parameter is included in the POST header. If I detached the DHTMLX Form from DHTMLX Layout, everything work fine. The code is as follow:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>User Group Search</title>
<link rel="stylesheet" type="text/css" href="../script/dhtmlxLayout/codebase/dhtmlxlayout.css">
<link rel="stylesheet" type="text/css" href="../script/dhtmlxLayout/codebase/skins/dhtmlxlayout_dhx_blue.css">
<link rel="stylesheet" type="text/css" href="../script/dhtmlxGrid/codebase/dhtmlxgrid.css">
<link rel="stylesheet" type="text/css" href="../script/dhtmlxGrid/codebase/skins/dhtmlxgrid_dhx_blue.css">
<link rel="stylesheet" type="text/css" href="../script/dhtmlxMenu/codebase/skins/dhtmlxmenu_dhx_blue.css">
<link rel="stylesheet" type="text/css" href="../script/dhtmlxForm/codebase/skins/dhtmlxform_dhx_web.css">
<link rel="stylesheet" type="text/css" href="../script/dhtmlxTree/codebase/dhtmlxtree.css">
<script src="../script/dhtmlxcommon.js"></script>
<script src="../script/dhtmlxLayout/codebase/dhtmlxcontainer.js"></script>
<script src="../script/dhtmlxLayout/codebase/dhtmlxlayout.js"></script>
<script src="../script/dhtmlxForm/codebase/dhtmlxform.js"></script>
<script src="../script/dhtmlxMenu/codebase/dhtmlxmenu.js"></script>
<script src="../script/dhtmlxGrid/codebase/dhtmlxgrid.js"></script>
<script src="../script/dhtmlxGrid/codebase/dhtmlxgridcell.js"></script>
<script src="../script/dhtmlxTree/codebase/dhtmlxtree.js"></script>
<script src="../script/dhtmlxTree/codebase/ext/dhtmlxtree_start.js"></script>
<script src="../script/dhtmlx.js" type="text/javascript"></script>
<script src="../script/BarMenu.js" type="text/javascript"></script>
</head>
<body>
<div id="parentId" style="position: relative; width: 100%; height: 100%;"></div>
<script>
var main_layout = new dhtmlXLayoutObject('parentId', '3E');
//important
var a = main_layout.cells('a');
a.setHeight('100');
a.hideHeader();
a.fixSize(0, 1);
var str = [ {
type : "block",
list : [ {
type : "select",
name : "searchBy",
label : "Search by : ",
options : [ {
text : "User",
value : "User"
}, {
text : "Group",
value : "Group"
}, ],
labelWidth : 100,
inputWidth : 80
}, ]
}, {
type : "block",
list : [ {
type : "input",
name : "id",
label : "ID : ",
labelWidth : 100,
inputWidth : 180
}, {
type : "newcolumn"
}, {
type : "input",
name : "name",
label : "Name : ",
value : '<s:property value="name"/>',
labelWidth : 100,
inputWidth : 300,
offsetLeft : 20
}, ]
}, {
type : "block",
list : [ {
type : "select",
name : "division",
label : "Division : ",
options : [ {
text : "ADD",
value : "ADD"
} ],
labelWidth : 100,
inputWidth : 180
}, {
type : "newcolumn"
}, {
type : "select",
name : "team",
label : "Team : ",
labelWidth : 100,
inputWidth : 180,
value : "",
offsetLeft : 20
}, {
type : "newcolumn"
}, {
type : "button",
name : "form_button_1",
label : "Reset",
value : "Reset",
width : "80",
inputWidth : "50",
offsetLeft : 150
}, {
type : "newcolumn"
}, {
type : "button",
name : "form_button_2",
label : "Search",
value : "Search",
width : "80",
inputWidth : "50",
offsetLeft : 10
} ]
}, ];
var form_2 = a.attachForm(str);
form_2.setSkin('dhx_web');
form_2.attachEvent("onButtonClick",function(buttonID){
form_2.send("../searchUser/initial.action", "post", function(xml){
});
});
//Not important, just for integration with grid
var b = main_layout.cells('b');
b.hideHeader();
var grid_1 = b.attachGrid();
grid_1.setImagePath('../script/dhtmlxGrid/codebase/imgs/');
grid_1.setIconsPath('../script/dhtmlxGrid/codebase/imgs/');
grid_1.setHeader([ "ID", "Name", "Description", "Division", "Team" ]);
grid_1.setColTypes("ro,ro,ro,ro,ro");
grid_1.setColSorting('str,str,str,str,str');
grid_1.setInitWidths('100,300,425,150,150');
grid_1.init();
// grid_1.load('./grid2.xml', 'xml');
grid_1.load('../test1/createGridJason.action', 'json');
//Not important
var c = main_layout.cells('c');
c.setHeight('60');
c.hideHeader();
c.fixSize(0, 1);
var str2 = [
{
type : "block",
list : [ {
type : "button",
name : "form_button_4",
label : "Back",
value : "Back"
}, {
type : "newcolumn"
}, {
type : "button",
name : "form_button_1",
label : "Browse",
value : "Browse",
offsetLeft : 450
}, {
type : "newcolumn"
}, {
type : "button",
name : "form_button_3",
label : "Modify",
value : "Modify",
offsetLeft : 10
}, {
type : "newcolumn"
}, {
type : "button",
name : "form_button_2",
label : "Create",
value : "Create",
offsetLeft : 10
}, {
type : "newcolumn"
}, {
type : "button",
name : "form_button_5",
label : "Reset",
value : "Unlock User / Reset Password",
offsetLeft : 10
}, ]
},
];
var form_2 = c.attachForm(str2);
form_2.setSkin('dhx_web');
</script>
</body>
</html>
If form is detached from Layout, it returns following POST parameter to server:
searchBy=User&id=undefined&name=aaa&division=ADD&team=-1