I have a grid as follows :

Now I want a combobox editor in date column whose value will be populated depending on the value in code column. What I have already tried is given below. I think I could not call test2bak.php correctly under onBeforeEdit event of the grid. Code is given below :
<script type="text/javascript">
$(function(){
$('#dg').datagrid({
method: 'get',
url:'test1back.php',
onClickCell: onClickCell,
fitColumns:true,
singleSelect:true,
rownumbers:true,
loadMsg:'loading...',
height:'auto',
columns:[[
{field:'name',title:'name',width:200},
{field:'code',title:'Code',width:100},
{field:'dt',title:'Date',width:100,align:'center',
editor:{
type:'combobox',
options:{
valueField:'dt',
textField:'dt',
panelHeight:90,
required:true
}
}
}
]],
[color=red] onBeforeEdit: function(index,row){
var coldt = $(this).datagrid('getColumnOption', 'dt');
coldt.editor = {
options:{
url:'test2back.php?code='+row.code,
}
};
// coldt.combobox('reload', 'test2back.php?code='+row.code);
}[/color]
});
});
$.extend($.fn.datagrid.methods, {
editCell: function(jq,param){
return jq.each(function(){
var opts = $(this).datagrid('options');
var fields = $(this).datagrid('getColumnFields',true).concat($(this).datagrid('getColumnFields'));
for(var i=0; i<fields.length; i++){
var col = $(this).datagrid('getColumnOption', fields[i]);
col.editor1 = col.editor;
if (fields[i] != param.field){
col.editor = null;
}
}
$(this).datagrid('beginEdit', param.index);
for(var i=0; i<fields.length; i++){
var col = $(this).datagrid('getColumnOption', fields[i]);
col.editor = col.editor1;
}
});
}
});
var editIndex = undefined;
function endEditing(dg){
if (editIndex == undefined){return true}
if (dg.datagrid('validateRow', editIndex)){
dg.datagrid('endEdit', editIndex);
editIndex = undefined;
//var rec = $(this).datagrid('getSelected');
// save here
return true;
} else {
return false;
}
}
function onClickCell(index, field){
if (endEditing($(this))){
$(this).datagrid('selectRow', index)
.datagrid('editCell', {index:index,field:field});
editIndex = index;
}
}
</script>
I think some incorrect reference is there in onBeforeEdit event. Anybody please help me.
test2bak.php contains :
<?php
include("config.php");
$code = intval($_REQUEST['code']);
$sql = "select * from test2 where code=$code";
$rs = mysql_query($sql) or die('not found!');
if ($rs){
$items = array();
while($row = mysql_fetch_object($rs)){
array_push($items, $row);
}
$result["rows"] = $items;
echo json_encode($result);
} else {
echo json_encode(array('msg'=>'No section allocated with this user!'));
}
?>
Thanks in advance.