Master/slave DataTable

I have some questions regarding two bound DataTables where the slave is using the dataFeed property.
In the test setup I have:

  1. DataTable named “A”, populated using the url property with a custom proxy.
  2. DataTable named “B”, populated using the dataFeed property, also with custom Proxy.
  3. Form named “formX”.

The components are bound using

  1. $$(“formX”).bind($$(“A”));
  2. $$(“B”).bind($$(“A”));

When I use this setup the form is populated when I select an entry in DataTable “A” but I was under the impression that DataTable “B” would make a request to the url specified by the dataFeed property with “filter[id]=idOfSelectedRowInA” but that never happens.

Questions:

  1. Is it possible to bind two DataTable as I have described above?
  2. Is it possible to used dataFeed in DataTable “B” as I have described above?

Hello @PorkLip,

1\. Is it possible to bind two DataTable as I have described above?
2\. Is it possible to used dataFeed in DataTable “B” as I have described above?

It is indeed possible, although the end result is slightly different in the case of data components. Generally, when you are binding a form to a component, the dataFeed property will return a server request in the following format:

url?action=get&id=obj.id

In the case when the slave component is a data component, the dataFeed functions a bit differently. The basic function stays the same, but the issued server request format will be a bit different:

url?filter[id]=+obj.id

The required syntax will be a bit different in this case as well - you will have to specify the field that should be filtered inside of the bind() method.

Please take a look at the following example: https://snippet.webix.com/iljpe5l5.

As you can see, when you select an entry in the first datatable you will issue a server request that looks like url?filter[id]=id. The following filtering rule will return any id that matches the currently selected id in the first table, meaning the binding will work as expected (the second datatable will display the filtered value). Please note that the server has to account for this filtering rule and return the appropriate response. Unfortunately, I won’t be able to provide a snippet with a backend that would work under these conditions. You can read more about binding and its interactions with server-side data in our article.

The information about specifying the filter parameter name as a string in the second parameter of the bind() method was invaluable! That seemed to enable the binding and also solve any further problems with the filter parameter name. So in my example above I replaced
$$(“B”).bind($$(“A”));
with
$$(“B”).bind($$(“A”), “foreignKeyId”);
and then everything it works! The slave table will load its data from
dataFeed+"?filter[foreignKeyId]="+selectedObjectInMasterTable.id

It would be great if this information about the second parameter of the bind() method was added to at least these pages:
https://docs.webix.com/api__link__datacollection_bind.html
and
https://docs.webix.com/api__link__datarecord_datafeed_config.html

Thanks for the help Dzmitry!

Hey @PorkLip,

It would be great if this information about the second parameter of the bind() method was added to at least these pages

Right you are. We will look into making this information more accessible in the future, our apologies for any caused inconveniences and thank you for your concern.