Getting data from a datatable

I have a requirement where I need to get the whole content of a datatable and display it in a div element.Is there any method/way to get the whole content at once??

As json

var json = $$("datatable").serialize();

as HTML

$$("datatable").config.prerender = true;
$$("datatable").refresh();
var html = $$("datatable").$view.innerHTML;

Thank You!!