eLabSDK.ParentSample
Functions
| Name | Description |
|---|---|
| saveParent(parentID) | Set the parent sample for the current sample being edited. |
This updates the parent sample reference in the sample edit form by fetching the parent
sample's name and displaying it in the UI. The parent sample ID is stored in the form's
data attribute for submission. The dialog is automatically closed after setting the parent.
Use this when implementing parent sample selection functionality in sample edit forms.
saveMultipleSamplesParent(parentID, samplesToUpdate) | Set a parent sample for multiple samples at once (bulk operation).
This updates the parent sample reference for multiple samples in a single operation. The
method sends the parent ID and array of sample IDs to the server, displays success or error
notifications, and closes the modal dialog. Use this for bulk parent assignment operations
from sample lists, experiment sections, or advanced search results.
showParentSelector(sampleIDsToUpdate, callbackFunctionName) | Show the parent sample selector dialog for bulk parent assignment.
This displays a dialog allowing users to set or clear the parent sample for multiple samples.
The dialog checks user permissions before allowing the operation and provides options to:
- Set a new parent (opens sample picker)
- Clear existing parent
- Cancel operation
The method automatically handles both Inventory V1 and V2 interfaces, permission validation,
and displays appropriate success/error messages. Use this as the main entry point for bulk
parent sample operations.
saveParent(parentID)
Set the parent sample for the current sample being edited.
This updates the parent sample reference in the sample edit form by fetching the parent
sample's name and displaying it in the UI. The parent sample ID is stored in the form's
data attribute for submission. The dialog is automatically closed after setting the parent.
Use this when implementing parent sample selection functionality in sample edit forms.
Kind: global function
| Param | Type | Description |
|---|---|---|
| parentID | Array.<number> | Array containing the parent sample ID (typically single element) |
Example
// Set parent sample from picker
var parentSample = new eLabSDK.ParentSample();
var selectedParentID = [456];
eLabSDK.ParentSample.saveParent(selectedParentID);
// Parent sample name appears in form, dialog closes
Example
// Use with sample picker
var parentSample = new eLabSDK.ParentSample();
openSamplePicker(function(selectedSamples) {
if (selectedSamples.length > 0) {
eLabSDK.ParentSample.saveParent([selectedSamples[0].sampleID]);
}
});
saveMultipleSamplesParent(parentID, samplesToUpdate)
Set a parent sample for multiple samples at once (bulk operation).
This updates the parent sample reference for multiple samples in a single operation. The
method sends the parent ID and array of sample IDs to the server, displays success or error
notifications, and closes the modal dialog. Use this for bulk parent assignment operations
from sample lists, experiment sections, or advanced search results.
Kind: global function
| Param | Type | Description |
|---|---|---|
| parentID | Array.<number> | Array containing the parent sample ID (typically single element) |
| samplesToUpdate | Array.<number> | string | Array of sample IDs or comma-separated string of IDs to update |
Example
// Set parent for multiple samples from list
var parentSample = new eLabSDK.ParentSample();
var parentID = [789];
var sampleIDs = [101, 102, 103];
eLabSDK.ParentSample.saveMultipleSamplesParent(parentID, sampleIDs);
// Shows "Link to sample parent successfully updated"
Example
// Bulk set parent from selected samples
var parentSample = new eLabSDK.ParentSample();
var checkedSamples = eLabSDK.ParentSample.getCheckedSamples();
if (checkedSamples.length > 0) {
var parentID = [456];
eLabSDK.ParentSample.saveMultipleSamplesParent(parentID, checkedSamples);
}
Example
// Set parent with comma-separated string
var parentSample = new eLabSDK.ParentSample();
var sampleIDsString = '111,112,113';
eLabSDK.ParentSample.saveMultipleSamplesParent([789], sampleIDsString);
showParentSelector(sampleIDsToUpdate, callbackFunctionName)
Show the parent sample selector dialog for bulk parent assignment.
This displays a dialog allowing users to set or clear the parent sample for multiple samples.
The dialog checks user permissions before allowing the operation and provides options to:
- Set a new parent (opens sample picker)
- Clear existing parent
- Cancel operation
The method automatically handles both Inventory V1 and V2 interfaces, permission validation,
and displays appropriate success/error messages. Use this as the main entry point for bulk
parent sample operations.
Kind: global function
| Param | Type | Description |
|---|---|---|
| sampleIDsToUpdate | Array.<number> | string | Array of sample IDs or comma-separated string of IDs |
| callbackFunctionName | string | Name of callback function for legacy Inventory V1 browser |
Example
// Show parent selector for checked samples
var checkedSamples = eLabSDK.ParentSample.getCheckedSamples();
if (checkedSamples.length > 0) {
eLabSDK.ParentSample.showParentSelector(
checkedSamples,
'eLabSDK.ParentSample.saveParentFromSampleList'
);
} else {
alert('Please select samples first');
}
Example
// Show parent selector from experiment page
var experimentSamples = eLabSDK.ParentSample.getCheckedSampleIdsFromExperiment();
eLabSDK.ParentSample.showParentSelector(
experimentSamples,
'eLabSDK.ParentSample.saveParentFromExperiment'
);
Example
// Show parent selector with specific sample IDs
var sampleIDs = [123, 456, 789];
eLabSDK.ParentSample.showParentSelector(
sampleIDs,
'eLabSDK.ParentSample.saveMultipleSamplesParent'
);
Example
// Custom button to set parent
var setParentBtn = new eLabSDK.GUI.Button({
label: 'Set Parent',
icon: 'link',
action: function() {
var selected = getSelectedSampleIDs();
if (selected.length === 0) {
alert('No samples selected');
return;
}
eLabSDK.ParentSample.showParentSelector(
selected,
'myCustomCallback'
);
}
});
© 2023 eLabNext
Updated about 5 hours ago