The Function of a datatable Column template is always called on an onafterSelect event

Hello everyone,
It has only been a couple month that I am playing around with webix.
I am facing an issue on a very basic operation, so I am surely missing something here and hope for someone to bring me light!

Snippet

http://webix.com/snippet/80301477

Explanation

  • I have two datatables: TYPES and OBJECTS
  • I am trying to fill a column in TYPES with the actual number of data of OBJECTS.
  • In TYPES I made a column with a template function, which applies a filter on OBJECTS, then counts the data in OBJECTS, and reset the filter.
  • Also, after selecting a row in TPES, I apply a filter on OBJECTS.

Expected Behaviour

  • On loading, the TYPES will count data in OBJECTS and store the result in the specified column
  • After selecting a row of TYPES , OBJECTS will be filtered by the selected object attribute

Problem

The onAfterSelect event of TYPES triggers the counting function on the OBJECTS, thus resets my filter, thus nothing is being filtered in the end (cf the webix message of my snippet)

Questions

  • Is this a wanted behaviour? Why?
  • Can I achieve what I want in a smarter way?

Thanks a lot!

Hi,

Template handles the data representation and fires on each resize/select/etc. It’s not the best place to affect another component.

Instead, I suggest you aggregate the counts for each type in objects table and then update data in types. A raw solution is here: http://webix.com/snippet/2773c0cf

Besides, onAfterSelect can be replaced with data binding (as shown in the above sample).

Thank you for your answers. I did it your way, with some adjustments for my needs and data, and it seems to work fine.
Cheers