select_records¶
- select_records(field_name, all_records)¶
domain: client
language: javascript
class Item class
Description¶
Use the select_records method to add records to an item by selecting them from the lookup item of a field.
For example, this method is used in the Demo application to add tracks to an invoice by selecting them from Tracks catalog.
Parameters:
The
field_nameparameter is a field name of a lookup field of the itemIf the
all_recordsparameter is set to true, all selected records are added, otherwise the method omits existing records (they were selected earlier).
Example¶
function on_view_form_created(item) {
if (item.master) {
item.view_form.find('#new-btn').off('click.task').on('click', function() {
item.select_records('track');
});
}
The above code will display Tracks catalog with all buttons defined for the template.
To hide the elements, we might use below code:
function on_view_form_created(item) {
if (item.view_form.closest('.modal').length) {
item.view_form.find("#edit-btn").hide();
item.view_form.find("#delete-btn").hide();
item.view_form.find("#new-btn").hide();
}
}