Hello,
I don't know whats the problem but when I declare an onLoadSuccess function in my datagrid definition, this function is called 4 times, thereby making the whole idea useless.
I wanted to show an alert and open the detailview input box for the first row of a table if there are no data yet. The alert box opens 4 times until i can finally input the data.
My code:
$('#dg_exp').datagrid({
url: "get_experiments.php",
toolbar: '#toolbar',
nowrap: false, // more than 1 line per row allowed
idField: 'taskid',
rownumbers: true,
fitColumns:true, // no horizontal scrolling
pagination:true, // show refresh footer
singleSelect: true,
onLoadSuccess: inputexp, // function inputexp to open input mask
columns:[[
{field:'taskid',title:'',hidden:'true'}, // hidden col. with task id
{field:'title',title:'Title',width:100},
{field:'detail',title:'Details',width:150},
{field:'lit',title:'Literature',width:150},
{field:'datum',title:'Startdate',width:60},
{field:'nsteps',title:'# steps',width:40}
]]
});
function inputexp(data) { // call from onLoadSuccess in exp_dg
//
loadSuccess = false;
currentid = data.rows[0].taskid;
if (currentid !='N') return;
else { // no exp. yet -> fill row with index 0
// this messager box opens multiple times : !!!
$.messager.alert('My Experiment','Please fill your first experiment','info');
row = $(this).datagrid('getRows')[0];
row.isNewRecord = true; // to make 'insert' action
$('#dg_exp').datagrid('expandRow', 0);
$('#dg_exp').datagrid('selectRow', 0);
return;
}
}
Any ideas ?
Thanks very much in advance,
Chris