Версия:

Tables

Tables are primarily intended for displaying and manipulating data, but they also serve as an entry/start point for various custom functions that implement the project’s business logic.

This could include:

You can customize the table in almost any way, for example, by hiding the table body and leaving only the filter functionality for sending requests for analytics collection and subsequent graph rendering.


How to Create

Profile Creation

  1. You don’t have to create a separate profile for the table; you can use the class profile.
  2. If you need special settings different from the class settings, create a Client Object (see the section Creating Client Objects).

Placement in the Interface

1. In the Main Menu

You need to create a menu item of type “Element” in the menu editor (System -> Menu editor):

Such an element will appear in the menu, and when selected, the specified table will open. No code writing is required.

2. Inside a Form or Frame (in Layout)

In the HTML layout of a form or frame, you can specify a div with a specific class and data attributes:

<div data-tbls="CLASS_NAME.TABLE_CO_NAME" class="fn-child-tbl-holder marTop10"></div>

3. Via Code in Any Container

To create a table programmatically, you need to create an instance of MB.TableN and call the create method, passing a jQuery container.

Example:

const req_holder = dashboard.parentBlock.find('.dbrd-requests-container');

const req_table = new MB.TableN({  
   name: 'Requests',  
   client_object: 'table_request_work_dashboard',  
   class: 'request_work',  
   id: MB.Core.guid(),  
   parentObject: frameInstance,  
   parent: frameInstance,  
   parent_id: frameInstance.data.data.id,  
   destroy_on_reload: true,  
   externalWhere: []  
});

req_table.create(req_holder, function () {  
   // console.log('dashboard table rendered');  
});

Main Parameters:


JS Extension File

When a table is loaded, a JS file can be executed to extend its functionality.

Connection Conditions:

  1. The file must be located in public_src/html/tables/require/.
  2. The file name must match the Client Object name or (if not specified) be in the form table_<class_name>.
  3. The “Additional functionality” checkbox must be checked in the Client Object (or class) profile.

You can use public_src/html/tables/require/_gocore/table_example.js as a template.

Context Menu

In the extension file, you can add items to the tableInstance.ct_instance.ctxMenuData array. Each element is an object:

Example:

{  
   name: 'option2',  
   title: 'Other',  
   disabled: function(){  
       return false;  
   },  
   callback: function(){  
       const row = tableInstance.ct_instance.selectedRowIndex;
       const dataRow = tableInstance.data.data[row];
       const id = dataRow.id;

       // Getting all selected rows
       const selected = tableInstance.ct_instance.selection2.data;  
   }  
}

Other Functionality

Through the table instance, you can access all settings, data, and the current state (filters, search text, current page, etc.). You can inspect the object’s contents at runtime via the browser console: MB.Tables.tables.

You can implement any logic using built-in core components, external libraries, or even embed applications on React or other frameworks.