Class LABKEY.WebPart
Web Part class to render a web part into an existing page element. If you wish to render a Query web part, please use the LABKEY.QueryWebPart class instead.
Additional Documentation:
Defined in: WebPart.js.
Constructor Attributes | Constructor Name and Description |
---|---|
LABKEY.WebPart(config)
WebPart class to render a web part into an existing page element.
|
Config Attributes | Config Name and Description |
---|---|
The name of a CSS class available in the current page.
|
|
The container path in which this web part is defined.
|
|
Callback function that will be executed if an error occurs.
|
|
The type of frame to wrap around the web part's content.
|
|
Object containing name/value pairs that will be sent to the server as configuration
parameters for the web part.
|
|
Name of the web part ("Wiki", "Lists", etc.
|
|
ID of the element in which the web part should be rendered.
|
|
A scope object to use when calling the successCallback or errorCallback functions (defaults to this).
|
|
Callback function that will be executed after the web part content as been inserted into the page.
|
|
If true, no alert will appear if there is a problem rendering the QueryWebpart.
|
|
Overrides the web part's default title.
|
|
Overrides the hyperlink href around the web part's title.
|
Method Attributes | Method Name and Description |
---|---|
<static> |
LABKEY.WebPart.createReportWebpart(config)
This is a static method to generate a report webpart.
|
render()
Renders the WebPart to the div element specified in the configuration settings.
|
Class Detail
LABKEY.WebPart(config)
WebPart class to render a web part into an existing page element. If you wish to render a Query web part, please
use the LABKEY.QueryWebPart class instead.
Example for a Wiki web part:<div id='wikiTestDiv'/> <script type="text/javascript"> var wikiWebPartRenderer = new LABKEY.WebPart({ partName: 'Wiki', renderTo: 'wikiTestDiv', partConfig: {name: 'home'} }) wikiWebPartRenderer.render(); </script>
Example for a Report web part, from the Reagent Request Tutorial and Demo:<div id='reportDiv'>Loading...</div> <script type="text/javascript"> // This snippet draws a histogram of the current user's requests. // A partConfig parameter identifies the R report ('db:151') // used to draw the histogram. partConfig also // supplies a filter ('query.UerID~eq') to ensure that // R uses data for only the current user. Lastly, partConfig // provides R with an arbitrary URL parameter ('displayName') // to indicate the displayName of the user. var reportWebPartRenderer = new LABKEY.WebPart({ partName: 'Report', renderTo: 'reportDiv', containerPath: '/home/Study/demo/guestaccess', frame: 'title', partConfig: { title: 'Reagent Request Histogram', reportId: 'db:151', showSection: 'histogram', 'query.UserID~eq' : LABKEY.Security.currentUser.id, displayName: LABKEY.Security.currentUser.displayName }}); reportWebPartRenderer.render(); </script>
- Parameters:
- {Object} config
- Describes configuration properties for this class.
Config Detail
{String}
config.bodyClass
The name of a CSS class available in the current page. This class name will be applied to the tag that
contains the web part's body content.
{String}
config.containerPath
The container path in which this web part is defined. If not supplied,
the current container path will be used.
{Function}
config.failure
Callback function that will be executed if an error occurs. This function
should have two parameters: response and partConfig. The response parameter is the XMLHttpResponse
object, which can be used to determine the error code and obtain the error text if desired.
The partConfig parameter will contain all the parameters sent to the server.
{String}
config.frame
The type of frame to wrap around the web part's content. This can
be any one of the following:
- portal: (Default) Includes the standard portal frame around the web part content
- title: Includes a lighter frame around the web part content (title with line underneath)
- left-nav: Similar to the title frame, but enforces a thinner width.
- div: Includes the content in a simple <div> tag. Use the config.bodyClass parameter to set a CSS class for the div.
- dialog: Includes the content in a frame that looks similar to a dialog box.
- none: Includes no frame around the web part content
{Object}
config.partConfig
Object containing name/value pairs that will be sent to the server as configuration
parameters for the web part. Each web part defines its own set of config parameters. See the
Web Part Configuration Properties page for further information on these name/value pairs.
{String}
config.partName
Name of the web part ("Wiki", "Lists", etc.), as listed in the
"Add Web Part" drop-down menu on the portal page of the container.
{String}
config.renderTo
ID of the element in which the web part should be rendered.
Typically this is a div.
{Object}
config.scope
A scope object to use when calling the successCallback or errorCallback functions (defaults to this).
{Function}
config.success
Callback function that will be executed after the web part content as been inserted into the page.
{boolean}
config.suppressRenderErrors
If true, no alert will appear if there is a problem rendering the QueryWebpart. This is most often encountered if page configuration changes between the time when a request was made and the content loads. Defaults to false.
{String}
config.title
Overrides the web part's default title.
Note that titles are not displayed when config.frame is set to "none".
{String}
config.titleHref
Overrides the hyperlink href around the web part's title.
Note that titles are not displayed when config.frame is set to "none".
Method Detail
<static>
LABKEY.WebPart.createReportWebpart(config)
This is a static method to generate a report webpart. It is equivalent to LABKEY.WebPart with partName='Report'; however,
it simplifies the configuration
<div id='testDiv'/> <div id='testDiv2'/> <script type="text/javascript"> //a report can be loaded using its name, schema and query var reportWebpart = LABKEY.WebPart.createReportWebpart({ schemaName: 'laboratory', queryName: 'DNA_Oligos', reportName: 'My Report', renderTo: 'testDiv', webPartConfig: { title: 'Example Report', suppressRenderErrors: true }, reportProperties: { 'query.name~eq': 'Primer2' } }); reportWebpart.render(); //the report can also be loaded using its Id var reportWebpartUsingId = LABKEY.WebPart.createReportWebpart({ reportId: 'module:laboratory/schemas/laboratory/DNA_Oligos/Query.report.xml', renderTo: 'testDiv2', webPartConfig: { title: 'Example Report', suppressRenderErrors: true }, reportProperties: { 'query.name~eq': 'Primer2' } }).render(); </script>
- Parameters:
- config
- The config object
- {String} config.renderTo
- The Id of the element in which the web part should be rendered.
- {String} config.reportId Optional
- The Id of the report to load. This can be used in place of schemaName/queryName/reportName
- {String} config.schemaName Optional
- The name of the schema where the report is associated.
- {String} config.queryName Optional
- The name of the query where the report is attached.
- {String} config.reportName Optional
- The name of the report to be loaded.
- {String} config.title Optional
- The title that will appear above the report webpart
- {Object} config.webPartConfig Optional
- A optional config object used to create the LABKEY.WebPart. Any config options supported by WebPart can be used here.
- {Object} config.reportProperties Optional
- An optional config object with additional report-specific properties. This is equal to partConfig from LABKEY.Webpart
- Returns:
- A LABKEY.WebPart instance
render()
Renders the WebPart to the div element specified in the configuration settings.
- Returns:
- A transaction id for the async request that can be used to cancel the request (see Ext.Ajax.abort()).