The all plugin such as datagrid and treegrid is same as other jQuery plugins(find, html, val, etc), they all extend with jQuery.fn object.
There is no efficient way to determine the object type, but you can add a type option while creating your object and then read this type from the 'options' object or directly to determine its object like this:
var target = $('#tt').get(0); // the DOM object
if ($.data(target,'treegrid')){
alert('treegrid');
} else if ($.data(target,'datagrid')){
alert('datagrid')
}