eLabSDK.Page.SampleAdvancedSearch

Functions

NameDescription
addSearchCondition(config)Add a metadata field search condition to the advanced search page.

This programmatically adds a search filter condition to the sample advanced search interface.
The condition filters samples based on a custom metadata field value using the specified
comparison operator (exact match, before, after, less than, more than, etc.). The condition
appears in the search criteria list and is included when the search is executed. Use this
to pre-populate search filters, create saved searches, or build custom search interfaces.
addButtons(config) | Add multiple custom buttons to the advanced search page.

This adds one or more custom buttons to the advanced search interface, typically positioned
in the top-right area near the search button. Buttons can be placed before or after the
main search button. Use this to add custom export functions, saved searches, or additional
search-related operations.
addButton(button, [location]) | Add a single custom button to the advanced search page.

This is a convenience method for adding a single button to the advanced search interface.
It internally calls addButtons() with a single-element array. The button is positioned
at the specified location (typically 'top' near the search button). Use this when you
only need to add one button rather than multiple buttons.
triggerSearch() | Execute the advanced search with current search conditions.

This programmatically triggers the advanced search to run with all currently configured
search conditions. The search results are loaded and displayed on the results page. Use
this after programmatically adding search conditions, to implement custom search workflows,
or to integrate search execution into automated processes or custom UI elements.
onReady([event]) | Register or fire the onReady event for the advanced search page.

This event is triggered when the advanced search page has fully initialized and is ready
for interaction. Register a callback to execute code after the page loads, such as adding
custom buttons, pre-populating search conditions, or integrating external functionality.
Call without parameters to manually trigger the event.

addSearchCondition(config)

Add a metadata field search condition to the advanced search page.

This programmatically adds a search filter condition to the sample advanced search interface.
The condition filters samples based on a custom metadata field value using the specified
comparison operator (exact match, before, after, less than, more than, etc.). The condition
appears in the search criteria list and is included when the search is executed. Use this
to pre-populate search filters, create saved searches, or build custom search interfaces.

Kind: global function

ParamTypeDefaultDescription
configObjectConfiguration object for the search condition
config.sampleTypeMetaIDnumberThe sample type metadata field ID to search on
config.labelstringDisplay label for the metadata field (e.g., 'Concentration')
config.valueLabelstringDisplay label for the value (human-readable representation)
config.valuestringThe actual value to search for
config.conditionLabelstringDisplay label for the condition (e.g., 'equals', 'greater than')
[config.condition]string''exact''Condition operator: 'exact', 'before', 'after', 'less', 'more', etc.
[config.dateType]string''TEXT''Data type of the field: 'TEXT', 'DATE', 'NUMBER', etc.

Example

// Add search condition for concentration
eLabSDK.ready(function() {
  var searchPage = new eLabSDK.Page.SampleAdvancedSearch();
  
  searchPage.onReady(function() {
    this.addSearchCondition({
      sampleTypeMetaID: 123,
      label: 'Concentration',
      valueLabel: '10 mg/mL',
      value: '10',
      conditionLabel: 'greater than',
      condition: 'more',
      dateType: 'NUMBER'
    });
    
    // Execute the search
    this.triggerSearch();
  });
});

Example

// Add multiple search conditions
eLabSDK.ready(function() {
  var searchPage = new eLabSDK.Page.SampleAdvancedSearch();
  
  searchPage.onReady(function() {
    // Condition 1: pH = 7.4
    this.addSearchCondition({
      sampleTypeMetaID: 456,
      label: 'pH',
      valueLabel: '7.4',
      value: '7.4',
      conditionLabel: 'equals',
      condition: 'exact',
      dateType: 'NUMBER'
    });
    
    // Condition 2: Created after date
    this.addSearchCondition({
      sampleTypeMetaID: 789,
      label: 'Created Date',
      valueLabel: '2024-01-01',
      value: '2024-01-01',
      conditionLabel: 'after',
      condition: 'after',
      dateType: 'DATE'
    });
    
    this.triggerSearch();
  });
});

Example

// Load saved search
eLabSDK.ready(function() {
  var searchPage = new eLabSDK.Page.SampleAdvancedSearch();
  
  searchPage.onReady(function() {
    $.get('/api/savedsearches/123', function(savedSearch) {
      savedSearch.conditions.forEach(function(condition) {
        searchPage.addSearchCondition(condition);
      });
      
      console.log('Loaded saved search with ' + savedSearch.conditions.length + ' conditions');
      searchPage.triggerSearch();
    });
  });
});

addButtons(config)

Add multiple custom buttons to the advanced search page.

This adds one or more custom buttons to the advanced search interface, typically positioned
in the top-right area near the search button. Buttons can be placed before or after the
main search button. Use this to add custom export functions, saved searches, or additional
search-related operations.

Kind: global function

ParamTypeDefaultDescription
configObjectConfiguration object for adding buttons
[config.location]string''top''Location to place buttons (currently only 'top' supported)
config.buttonsArray.<eLabSDK.GUI.Button>Array of eLabSDK.GUI.Button instances to add
[config.before]booleanfalseIf true, place buttons before the main search button; if false, place after

Example

// Add multiple action buttons to search page
eLabSDK.ready(function() {
  var searchPage = new eLabSDK.Page.SampleAdvancedSearch();
  
  searchPage.onReady(function() {
    var saveSearchBtn = new eLabSDK.GUI.Button({
      label: 'Save Search',
      icon: 'save',
      action: function() {
        saveCurrentSearch();
      }
    });
    
    var loadSearchBtn = new eLabSDK.GUI.Button({
      label: 'Load Search',
      icon: 'folder-open',
      action: function() {
        openSavedSearches();
      }
    });
    
    this.addButtons({
      location: 'top',
      buttons: [saveSearchBtn, loadSearchBtn],
      before: false
    });
  });
});

Example

// Add export button before search button
eLabSDK.ready(function() {
  var searchPage = new eLabSDK.Page.SampleAdvancedSearch();
  
  searchPage.onReady(function() {
    var exportBtn = new eLabSDK.GUI.Button({
      label: 'Export Results',
      icon: 'download',
      action: function() {
        exportSearchResults();
      }
    });
    
    this.addButtons({
      buttons: [exportBtn],
      before: true
    });
  });
});

addButton(button, [location])

Add a single custom button to the advanced search page.

This is a convenience method for adding a single button to the advanced search interface.
It internally calls addButtons() with a single-element array. The button is positioned
at the specified location (typically 'top' near the search button). Use this when you
only need to add one button rather than multiple buttons.

Kind: global function

ParamTypeDefaultDescription
buttoneLabSDK.GUI.ButtonAn eLabSDK.GUI.Button instance to add
[location]string'&#x27;top&#x27;'Location to place the button (currently only 'top' supported)

Example

// Add single export button
eLabSDK.ready(function() {
  var searchPage = new eLabSDK.Page.SampleAdvancedSearch();
  
  searchPage.onReady(function() {
    var exportBtn = new eLabSDK.GUI.Button({
      label: 'Export CSV',
      icon: 'file-csv',
      action: function() {
        exportResultsToCSV();
      }
    });
    
    this.addButton(exportBtn, 'top');
  });
});

Example

// Add saved search button
eLabSDK.ready(function() {
  var searchPage = new eLabSDK.Page.SampleAdvancedSearch();
  
  searchPage.onReady(function() {
    var savedSearchBtn = new eLabSDK.GUI.Button({
      label: 'My Saved Searches',
      icon: 'star',
      action: function() {
        openSavedSearchesDialog();
      }
    });
    
    this.addButton(savedSearchBtn);
  });
});

triggerSearch()

Execute the advanced search with current search conditions.

This programmatically triggers the advanced search to run with all currently configured
search conditions. The search results are loaded and displayed on the results page. Use
this after programmatically adding search conditions, to implement custom search workflows,
or to integrate search execution into automated processes or custom UI elements.

Kind: global function
Example

// Execute search after adding conditions
eLabSDK.ready(function() {
  var searchPage = new eLabSDK.Page.SampleAdvancedSearch();
  
  searchPage.onReady(function() {
    // Add search conditions
    this.addSearchCondition({
      sampleTypeMetaID: 123,
      label: 'Status',
      valueLabel: 'Active',
      value: 'Active',
      conditionLabel: 'equals',
      condition: 'exact'
    });
    
    // Execute the search
    this.triggerSearch();
  });
});

Example

// Custom search button
eLabSDK.ready(function() {
  var searchPage = new eLabSDK.Page.SampleAdvancedSearch();
  
  searchPage.onReady(function() {
    var quickSearchBtn = new eLabSDK.GUI.Button({
      label: 'Quick Search',
      icon: 'search',
      action: function() {
        // Add predefined conditions
        searchPage.addSearchCondition({
          sampleTypeMetaID: 456,
          label: 'Type',
          valueLabel: 'Chemical',
          value: 'Chemical',
          condition: 'exact'
        });
        
        // Execute
        searchPage.triggerSearch();
      }
    });
    
    this.addButton(quickSearchBtn);
  });
});

Example

// Load and execute saved search
eLabSDK.ready(function() {
  var searchPage = new eLabSDK.Page.SampleAdvancedSearch();
  
  searchPage.onReady(function() {
    // Load saved search criteria
    $.get('/api/savedsearches/789', function(savedSearch) {
      savedSearch.conditions.forEach(function(condition) {
        searchPage.addSearchCondition(condition);
      });
      
      // Execute the loaded search
      searchPage.triggerSearch();
      console.log('Executed saved search');
    });
  });
});

onReady([event])

Register or fire the onReady event for the advanced search page.

This event is triggered when the advanced search page has fully initialized and is ready
for interaction. Register a callback to execute code after the page loads, such as adding
custom buttons, pre-populating search conditions, or integrating external functionality.
Call without parameters to manually trigger the event.

Kind: global function
Returns: functionundefined - The registered callback if provided, or undefined if firing event

ParamTypeDescription
[event]functionOptional callback function to register for the event

Example

// Add custom functionality after page loads
eLabSDK.ready(function() {
  var searchPage = new eLabSDK.Page.SampleAdvancedSearch();
  
  searchPage.onReady(function() {
    console.log('Advanced search page is ready');
    
    // Add custom button
    var myBtn = new eLabSDK.GUI.Button({
      label: 'Custom Action',
      icon: 'magic',
      action: function() {
        performCustomAction();
      }
    });
    this.addButton(myBtn);
  });
});

Example

// Pre-populate search with conditions
eLabSDK.ready(function() {
  var searchPage = new eLabSDK.Page.SampleAdvancedSearch();
  
  searchPage.onReady(function() {
    // Load user's default search
    var defaultSearch = getUserDefaultSearch();
    
    defaultSearch.conditions.forEach(function(condition) {
      searchPage.addSearchCondition(condition);
    });
    
    console.log('Loaded default search criteria');
  });
});

© 2023 eLabNext