I've got a complicated datagrid based upon the edit grid. The data loads from json via a database and shows up on the page. When the json returns an empty value on page load '[]' it shows up correctly as the datagrid with no footer rows. However if I add a record and then delete one, not only does the footer rows remain visible but also does not update its value.
I'm trying to get the datagrid to do one of the following:
reload the datagrid correctly and show properly
give me a count of the rows in the datagrid so I can find out if it is zero and kick the user over to a different page.
function destroyItem(){
var row = $('#dg').datagrid('getSelected');
if (row){
$.messager.confirm('Confirm','Are you sure you want to remove this row?',function(r){
if (r){
var index = $('#dg').datagrid('getRowIndex',row);
jqab = $.post('destroy_row.php',{idhz_timesheets:row.idhz_timesheets},function(){
$('#dg').datagrid('deleteRow',index);
});
jqab.always(function(){
getHours($('#userid').val());
});
}
//This is the line that is misbehaving.
$('#dg').datagrid('reload');
});
}
}
Here's the json that is returned from the datagrid load with 1 record. It will load [] if it is empty.
{"total":1,"rows":[{"idhz_timesheets":"211","user":"Test User","joblevel":"Foreman","isForeman":"1","isJourneyman":"0","isApprentice":"0","taskcode":"0100-Site","hours":"7.00","date":"2014-05-01","comments":"7"}],"footer":[ {},{"taskcode":"Foreman Hours :","hours":"7.00"},{"taskcode":"Journeyman Hours:","hours":"0.00"},{"taskcode":"Apprentice Hours :","hours":"0.00"},{"taskcode":"Total Hours :","hours":"7.00"}]}