Skip to content

Design Discussions Table Linking

chrisjstevo edited this page Feb 5, 2021 · 7 revisions

Table Linking

Table linking is the ability to change a filter on one grid in the client, based on the selected rows in another grid.

An example of this might be linking a grid of orders on a given product by selecting the product grid. If I selected the product Vodafone, I would see all orders that are there for Vodafone

Client Solution

One way to implement this behaviour is completely on the client. We could create an RPC table on the server, when a user selects a row on the products grid we would add the key to the rpc server table, then we would creating a join table that showed the rpc server table joined to orders by the foreign key product id.

Server Solution

Another way to implement this behaviour entirely on the view server would be in the following way:

  1. Allow a user to create a viewport which is linked to the "selection" in another viewport, equivalently "select from orders where productId in (products.selection.productId)"
  2. When a user clicks on a grid row, a changedRowSelection() msg would be sent to the server up with the rows keys (or indices) which would be stored on in the viewport
  3. When the viewport thread runs, the orders viewport would reference the products.selected field of the products viewport to perform the filter.
  4. The filtered rows would be passed back to the client.

Some considerations to keep in mind:

  • We would want to be able to link and unlink a viewport based on toggling on the UI. So this operation should be cheap, it shouldn't require the teardown of an existing viewport.
  • How would direction work? I assume we'd create the child viewport (products) and link it to the parent (orders). Which implies the directionality.
  • How would we identify the keys we could link on? Would the table definitions export some kind of link-able keys in the table def? (orders.orderId, orders.productId), would it be statically defined? (i.e. you can link from products.productId -> orders.productId, but not products.ric -> orders.ric?)
  • What would happen in the event we had selected row 6 (KEY = 110) for example, and then due to a sort the data in row 6 becomes (KEY = 999) does the selection stay with the row index or the row key? (if its the row key it has to be within the vp range I assume)