Suppose each rows have 'count' property to determine if to show the expander icon or not. The code below shows how to achieve this functionality.
$('#dg').datagrid({
onLoadSuccess:function(data){
for(var i=0; i<data.rows.length; i++){
if (data.rows[i].count == 0){
$(this).datagrid('getExpander', i).hide();
}
}
}
});