On UI,Fields in grid are getting edited and added properly, but not reflected in database.Only one field is reflecting in database other values are going null.What can be the problem?
Html code
[code]dhtmlxEvent(window, “load”, function() {
var layout = new dhtmlXLayoutObject(document.body, “2U”);
layout.cells(“a”).setText(“Add New Parent”);
layout.cells(“b”).setText(“Parent Details”);
layout.cells(“b”).setWidth(500);
///Form
var contactForm = layout.cells("b").attachForm();
contactForm.loadStruct("data/form.xml");
//Toolbar
var toolbar = layout.attachToolbar();
toolbar.setIconsPath("icons/");
toolbar.loadStruct("data/toolbar.xml");
//Grid
var myGrid = layout.cells("a").attachGrid();
// myGrid = new dhtmlXGridObject(‘gridbox’);
myGrid.attachHeader("#text_filter,#text_filter,#text_filter,#text_filter,#text_filter");
myGrid.setImagePath(“img/”);
myGrid.setHeader(“1,2,3,4,5”);
myGrid.setColumnIds(“ParentCustomerName,EndActiveDate,Comments,Active,AddInfo”);
//myGrid.setColTypes(“ro,ed,ed,ed”); //the types of columns
myGrid.setColSorting(“str,str,str,str,str”);
myGrid.init();
myGrid.load("/Practice/form", “xml”);
//Bind Data To Grid
contactForm.bind(myGrid);
contactForm.attachEvent("onButtonClick", function(name, command){
contactForm.save();
});
//DataProcessor
var dpg = new dataProcessor("/Practice/form"); //inits dataProcessor
dpg.init(myGrid);
dpg.attachEvent("onAfterUpdate", function(sid, action, tid, tag){
if (action == "inserted"){
myGrid.selectRowById(tid); //selects the newly-created row
contactForm.setFocusOnFirstActive();//set focus to the 1st form's input
}
});
toolbar.attachEvent("onclick",function(id){
if(id=="newContact"){
var rowId=myGrid.uid();
var pos = myGrid.getRowsNum();
myGrid.addRow(rowId,["New contact","",""],pos);
myGrid.selectRowById(rowId);
contactForm.setFocusOnFirstActive();
};
if(id=="delContact"){
var rowId = myGrid.getSelectedRowId();
var rowIndex = myGrid.getRowIndex(rowId);
if(rowId!=null){
myGrid.deleteRow(rowId);
if(rowIndex!=(myGrid.getRowsNum()-1)){
myGrid.selectRow(rowIndex+1,true);
} else{
myGrid.selectRow(rowIndex-1,true);
}
}
}
});
});
[/code]
Java Code
[code]@Override
protected void configure() {
//obtain DB connection
Connection conn=null;
try {
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection("jdbc:mysql://localhost/test", "root", "ganeshay");
java.sql.Statement stmt = conn.createStatement();
//
// ResultSet rs = stmt.executeQuery(“select * from details”);
} catch (Throwable e) {
e.printStackTrace();
}
//Initializes connector
GridConnector c = new GridConnector(conn,DBType.MySQL);
//configures the used table and fields
c.render_table("parent","ParentId","ParentCustomerName","EndActiveDate,Comments,Active,AddInfo");[/code]
form.xml
[code]
<item type="input" label="Parent Customer Name" name="ParentCustomerName" offsetLeft="15"/>
<item type="input" label="End Active Date" name="EndActiveDate" offsetLeft="15"/>
<item type="input" label="Comments" name="Comments" offsetLeft="15"/>
<item type="input" label="Active" name="Active" offsetLeft="15"/>
<item type="input" label="Additional Information" name="AddInfo" offsetLeft="15"/>
<item type="button" value="Add" offsetTop="15" offsetLeft="230"/>
[/code]