1 /*
  2  * Copyright (c) 2014 LabKey Corporation
  3  *
  4  * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
  5  */
  6 
  7 LABKEY.Query.GetData = new function(impl) {
  8 
  9     /**
 10      * Documentation specified in core/GetData.js -- search for "@name renderQueryWebPart"
 11      */
 12     impl.renderQueryWebPart = function(config) {
 13         var jsonData = validateGetDataConfig(config);
 14         jsonData.renderer.type = 'json';
 15         jsonData.renderer.maxRows = 0;
 16 
 17         if (!config.webPartConfig) {
 18             throw new Error("A webPartConfig object is required.");
 19         }
 20 
 21         var requestConfig = {
 22             method: 'POST',
 23             url: LABKEY.ActionURL.buildURL('query', 'getData', config.source.containerPath),
 24             jsonData: jsonData,
 25             success: function(response){
 26                 var json = LABKEY.Utils.decode(response.responseText);
 27                 config.webPartConfig.schemaName = config.source.schemaName;
 28                 config.webPartConfig.queryName = json.queryName;
 29                 new LABKEY.QueryWebPart(config.webPartConfig);
 30             },
 31             failure: function(response, options) {
 32                 if (response.status != 0) {
 33                     LABKEY.Utils.displayAjaxErrorResponse(response, null, true, "Error during GetData call");
 34                 }
 35             }
 36         };
 37 
 38         LABKEY.Ajax.request(requestConfig);
 39     };
 40     return impl;
 41 
 42 }(LABKEY.Query.GetData);
 43