Common Configurations of the Trials Viewer Widget
Below are code snippets that demonstrate some common ways you can embed the Trials Viewer widget on a page.
Table View Filtered by Recruiting Status And Single Condition
$(document).ready(function() {
$("#search_results_container").trialsViewer({
filter: { // Any parameter accepted by the backing CT api call can be used here.
conditions: 8, // Can be an array of ids or a single id
recruitingStatus: 'RECRUITING'
}
});
});
Table View Filtered by Mutliple Conditions
$(document).ready(function() {
$("#search_results_container").trialsViewer({
filter: {
conditions: [ 8, 1, 4]
}
});
});
Table View Filtered by Named Condition
$(document).ready(function() {
$("#search_results_container").trialsViewer({
filter: {
condition: 'Cancer'
},
// This overrides the default CT api endpoint, if used, the filter option must specify parameters that are valid for this call
trialsListUrl: 'trials/search?limit=1000'
});
});
Table View No Filter
$(document).ready(function() {
$("#search_results_container").trialsViewer({
// If not using filters, the search url must be used otherwise you'll get errors
trialsListUrl: 'trials/search?limit=1000'
});
});
Table View Sorted Coloumn Order
$(document).ready(function() {
$("#search_results_container").trialsViewer({
trialsListUrl: 'trials/search?limit=1000',
columns: [ 'studyTitle', 'investigator', 'condition' ]
// Available options are studyTitle, investigator, condition, recruitingStatus and contactInfo
// By default, studyTitle, investigator and recruitingStatus are displayed
// Order specified is render order, also css can be provided to override default column widths
});
});
List View Filtered Conditions
$(document).ready(function() {
$("#search_results_container").trialsViewer({
filter: {
conditions: [ 1, 3, 8 ]
},
// List view is disabled by default, if this property is set to true it overrides the columns setting
listView: true
});
});
Filter Widget
$(document).ready(function() {
$("#trial_details_container").filterWidget({
filter: {
condition: 'Ewing Sarcoma',
recruitingStatus: 'RECRUITING'
},
buttonLabel: 'Search Trials'
});
});
});
Filter Widget with URL for 0 Results
Use the "noTrialsUrl" parameter when you want to specify a URL for the target of the button in case no results are returned.
$(document).ready(function() {
$("#trial_details_container").filterWidget({
filter: {
condition: 'Ewing Sarcoma',
recruitingStatus: 'RECRUITING'
},
buttonLabel: 'Search Trials',
noTrialsUrl: 'http://stanfordhospital.org'
});
});
});
Filter Widget with Multiple Conditions
Use the "conditionDisplayText" parameter for the text to be displayed when there are multiple conditions.
$(document).ready(function() {
$(function() {
$("#trial_details_container").filterWidget({
filter: {
conditions: [40, 39],
recruitingStatus: 'RECRUITING'
},
buttonLabel: 'Search Trials',
noTrialsUrl: 'http://stanfordhospital.org',
conditionDisplayText: 'Sarcoma',
trialsListUrl: '/trials'
});
});
});

