The following code works fine as javascript that is behind the aspx page, however if it is called from a standalone JS file it bombs out. What is the correct code to locate a datagrid on a page.
var masterTable = $find("<%=dgServices.ClientID %>").get_masterTableView();
Javascript external files are not run through the ASP.NET engine, so the server tag <%=...%> is never executed in that case. In order to access any control ClientID, use a global variable in the aspx file itself, and save the ClientID when page loads. Now you will be able to access the control (from external JS file) uisng the ClientID saved in global variable.