Hi all,
This Apologies is sort of a long one, so please be a little patient
Background:
I have a grid that is populated with data from a db what I’ve been trying to do is use a form to allow updating, addition and deletion to the grid which would also update the db I’ve followed the tutorial regarding do this but when ever I try and trigger one of the CRUD functions I get the following error
Here is the page code im using:
function load_TransportGrid() {
transportGrid = new dhtmlXGridObject('transportGridContainer');
// create the transport grid
transportGrid .setImagePath("codebase/imgs/");
transportGrid .setHeader("Transport code,Transport name,Preference level,Options");
transportGrid .attachHeader("#text_filter,#text_filter,#numeric_filter");
transportGrid .setColumnIds("Transport_Type_ID,Transport_Name,Preference_Level,Options");
transportGrid .setInitWidths("80,110,110,60");
transportGrid .setColAlign("left,right,right,right,right");
transportGrid .setSkin("modern");
transportGrid .setColSorting("str,str,str,int");
transportGrid .setColTypes("ro,ro,ed,ro");
transportGrid.enableCellIds(true);
transportGrid .init();
transportGrid .load("resources/lib/cons/transportPreferences_gridConfig.php",function () {
{
for (var i = 0; i < transportGrid.getRowsNum(); i ++ ) {
var cellObj = transportGrid.cellByIndex(i,3);
var cellValue = "<input type='image' id='delete' src='imgs/delete.jpg' alt='Zoom on location' WIDTH='20' HEIGHT='20' onClick = 'deleteTransportType()'> ";
cellObj.setCValue(cellValue);
}
}
});
// define settings for the transport grid and initialise it.
transportFormStructure = [
{type:"settings",position:"label-top"},
{type: "fieldset", name:"addTransportSel", label:"Add transport preference ", list:[
{type: "select", label: "Name:", options:[
{text: "Car", value: "Car"},
{text: "Train", value: "Train"},
{text: "Bus", value: "Bus"},
{text: "Coach", value: "Coach"}
]},
{type:"newcolumn"},
{type:"select",offsetLeft: 2,name:"addTransportPrefSel",label:"Preferenece Level" ,offsetLeft:30,options:[
{text: "1",value: "1"},
{text: "2",value:"2"},
{text:"3",value:"3"}
]},
{type:"newcolumn"},
{type: "button", name:"add_transport_btn", value:"Add",offsetTop:10}
]}
]
// create a new list containing form elements to define its structure
transportForm = new dhtmlXForm("transportFormContainer",transportFormStructure);
transportForm.attachEvent("onButtonClick",function(id){
if (id =='add_transport_btn') {
addTransportType();
}
else if (id =='update_transport_btn') {
}
})
transportForm.bind(transportGrid);
transportDataprocessor = new dataProcessor ("resources/lib/cons/transportPreferences_gridConfig.php");
transportDataprocessor.init(transportGrid);
transportDataprocessor.enableDataNames(true);
transportDataprocessor.setTransactionMode("Get");
}
function deleteTransportType() {
var selectedItem = transportGrid.getSelectedRowId();
transportGrid.deleteRow(selectedItem);
}
function addTransportType() {
var areaCode = [b]transportForm.getItemValue("addAreaSel");[/b]
var areaName = [b]transportForm.getItemText("addAreaSel");[/b]
var prefLevel = transportForm.getItemValue("addAreaPrefSel");
var inputString = areaName + ","+ prefLevel;
transportGrid.addRow(areaCode, inputString,0);
}
and this is the connector code:
[code]$grid_conn = new GridConnector($conn, “MySQL”);
// intilize the connector
$id = $_SESSION [‘ID’];
// get the users id for the query.
$grid_conn ->render_sql(“SELECT transport_preferences.Transport_Type_ID,
transport_preferences.Preference_Level,
ltransport_type.Description
FROM transport_preferences,ltransport_type
WHERE transport_preferences.Transport_Type_ID =
ltransport_type.Transport_Type_ID
AND transport_preferences.User_ID = $id”,"",“Transport_Type_ID,Transport_Name,Preference_Level”);
// render the table
?>
[/code]
Im pretty sure the bits in bold are wrong because they are returning null, but im not sure how to get a selection boxes text and values, could this be the issue?
If not can anybody give me some idea what the problem is?
Any help very much appreciated,Ive been at this for 2 days now and Im on a deadline .
Thanks in advance.