Notice that your datagrid is placed on center panel of layout. The code below can get the datagrid outer height.
var height = $('body').layout('panel','center').height();
alert(height);
Another way to get the height of datagrid is to get the outer panel of datagrid and then get its height.
var height = $('#dg').datagrid('getPanel').panel('panel').outerHeight();
alert(height);