eLabSDK.Experiment.Section

Members

NameDescription
type

Functions

NameDescription
getMeta()Get the custom metadata fields for this experiment section.

This retrieves the array of custom metadata field values associated with the section.
Metadata fields are custom properties that store additional information beyond the
standard section fields. Each section type can have its own set of metadata fields.
Returns an array of metadata objects containing field definitions and values. Use this
to access custom section properties for display, validation, or processing.
onUpdateReady([event]) | Register or fire the onUpdateReady event for this section.

This event is triggered when the section has completed an update operation and is ready
for further interaction. Register a callback to be notified when updates complete, or
call without parameters to manually trigger the event. Use this to coordinate UI updates,
refresh displays, or chain operations after section modifications.
onLoaded([event]) | Register or fire the onLoaded event for this section.

This event is triggered when the section data has been loaded from the server or after
the section has been created. Register a callback to be notified when loading completes,
or call without parameters to manually trigger the event. This is the primary way to
execute code after section initialization. Use this to access section data, add content,
or perform operations that require the section to be fully loaded.

type

Kind: global variable
Properties

NameType
object.typeeLabSDK.Experiment.Section.SECTIONTYPE

getMeta()

Get the custom metadata fields for this experiment section.

This retrieves the array of custom metadata field values associated with the section.
Metadata fields are custom properties that store additional information beyond the
standard section fields. Each section type can have its own set of metadata fields.
Returns an array of metadata objects containing field definitions and values. Use this
to access custom section properties for display, validation, or processing.

Kind: global function
Returns: Array.<Object> - Array of metadata objects containing custom field data
Example

// Get section metadata after loading
var section = new eLabSDK.Experiment.Section({
  sectionID: 123
});
section.onLoaded(function() {
  var metadata = this.getMeta();
  console.log('Section has ' + metadata.length + ' custom fields');
  metadata.forEach(function(field) {
    console.log(field.name + ': ' + field.value);
  });
});

Example

// Find specific metadata field value
var section = new eLabSDK.Experiment.Section({
  sectionID: 456
});
section.onLoaded(function() {
  var metadata = this.getMeta();
  var temperature = metadata.find(function(field) {
    return field.name === 'Temperature';
  });
  if (temperature) {
    console.log('Section temperature: ' + temperature.value + '°C');
  }
});

Example

// Display metadata in UI
var section = new eLabSDK.Experiment.Section({
  sectionID: 789
});
section.onLoaded(function() {
  var metadata = this.getMeta();
  var $container = $('#sectionMetadata');
  metadata.forEach(function(field) {
    $container.append(
      '<div class="meta-field">' +
      '<strong>' + field.name + ':</strong> ' +
      '<span>' + field.value + '</span>' +
      '</div>'
    );
  });
});

onUpdateReady([event])

Register or fire the onUpdateReady event for this section.

This event is triggered when the section has completed an update operation and is ready
for further interaction. Register a callback to be notified when updates complete, or
call without parameters to manually trigger the event. Use this to coordinate UI updates,
refresh displays, or chain operations after section modifications.

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

// Register callback for when section update completes
var section = new eLabSDK.Experiment.Section({
  sectionID: 123
});
section.onUpdateReady(function() {
  console.log('Section update completed');
  refreshSectionDisplay();
});

Example

// Chain operations after update
var section = new eLabSDK.Experiment.Section({
  sectionID: 456
});
section.onUpdateReady(function() {
  console.log('Section ready after update');
  loadAdditionalData();
});

onLoaded([event])

Register or fire the onLoaded event for this section.

This event is triggered when the section data has been loaded from the server or after
the section has been created. Register a callback to be notified when loading completes,
or call without parameters to manually trigger the event. This is the primary way to
execute code after section initialization. Use this to access section data, add content,
or perform operations that require the section to be fully loaded.

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

// Register callback for when section loads
var section = new eLabSDK.Experiment.Section({
  sectionID: 123
});
section.onLoaded(function() {
  console.log('Section loaded successfully');
  console.log('Section type: ' + this.type.name);
  console.log('Section data:', this.data);
});

Example

// Access metadata after section loads
var section = new eLabSDK.Experiment.Section({
  sectionID: 456
});
section.onLoaded(function() {
  var metadata = this.getMeta();
  metadata.forEach(function(field) {
    console.log(field.name + ': ' + field.value);
  });
});

Example

// Create and use section
var experiment = new eLabSDK.Experiment({
  experimentID: 789,
  onLoaded: function() {
    var section = new eLabSDK.Experiment.Section({
      experiment: this,
      sectionID: 0,
      sectionHeader: 'New Section',
      sectionType: 'PARAGRAPH'
    });
    section.onLoaded(function() {
      console.log('New section created with ID: ' + this.options.sectionID);
    });
  }
});

.registerType(type)

Register a custom section type for use in experiments.

This static method allows you to register new custom section types beyond the built-in types
(SAMPLESIN, SAMPLESOUT, FILE, PARAGRAPH). Custom section types are added to the SECTIONTYPE
enum and automatically assigned the next available value. Once registered, custom sections
can be created and used just like built-in section types. Use this when building plugins or
extensions that add new types of content to experiments.

Kind: static function

ParamTypeDescription
typeObjectConfiguration object for the custom section type
type.namestringThe unique name for this section type (e.g., 'CUSTOM_DATA', 'CHART')
[type.rootVar]stringOptional root variable name for the custom section implementation
[type.version]stringOptional version string for the custom section type

Example

// Register a custom chart section type
eLabSDK.Experiment.Section.registerType({
  name: 'CHART',
  rootVar: 'ChartSection',
  version: '1.0.0'
});

// Now you can use it like built-in types
var experiment = new eLabSDK.Experiment({
  experimentID: 123,
  onLoaded: function() {
    this.addSection({
      sectionHeader: 'Results Chart',
      sectionType: eLabSDK.Experiment.Section.SECTIONTYPE.CHART,
      onCreated: function() {
        console.log('Custom chart section created');
      }
    });
  }
});

Example

// Register custom data table section
eLabSDK.Experiment.Section.registerType({
  name: 'CUSTOM_TABLE',
  rootVar: 'CustomTableSection',
  version: '2.1.0'
});

console.log('Registered section type: ' + 
  eLabSDK.Experiment.Section.SECTIONTYPE.CUSTOM_TABLE.name);

Example

// Register multiple custom types
var customTypes = [
  { name: 'SPECTROMETRY', rootVar: 'SpectrometrySection' },
  { name: 'MICROSCOPY', rootVar: 'MicroscopySection' },
  { name: 'SEQUENCE', rootVar: 'SequenceSection' }
];

customTypes.forEach(function(type) {
  eLabSDK.Experiment.Section.registerType(type);
});

console.log('Registered ' + customTypes.length + ' custom section types');

© 2023 eLabNext