Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ListGrid with related DataSource and multicolumn primary keys - BUG?

    Hi,

    I am using version 2012-10-22 LGPL.

    I have ListGrid with DataSource using two columns as primary key. The ListGrid can expand to show related records from another DataSource which also single primary key and two columns with foreignKey directed to first DataSource.
    Unfortunately when expanding only first column with primaryKey is taken into consideration and expanded ListGrid show much to many records.

    Code:
    DataSource.create({
      ID: "orders_lines",
      fields: [
        {name: "order_id", primaryKey: true},
        {name: "product_id", primaryKey: true},
        {name: "quantity"},
        {name: "price"}
      ]
    });
    
    DataSource.create({
      ID: "orders_lines_items",
      fields: [
        {name: "item_id", primaryKey: true},
        {name: "order_id", foreignKey: "orders_lines.order_id"},
        {name: "product_id", foreignKey: "orders_lines.product_id"},
        {name: "reservered"}
      ]
    });
    
    ListGrid.create({
      dataSource: "orders_lines",
      canExpandRecords: true,
      expansionMode: "related",
      detailDS: "orders_lines_items"
    });
    Actual result:
    When expanding row in ListGrid related records are filtered only by "order_id".

    Expected result:
    Related records should be filtered by "order_id" and "product_id".

    Best regards,
    Janusz

    #2
    Any chances, that somebody could confirm that?

    Comment


      #3
      I'm having exactly the same problem, is it a bug?

      Comment


        #4
        No, not a bug. Two foreignKey declarations as shown do not, on their own, tell the system that there is a many-to-one relationship from orders_lines_items to orders_lines using *both* keys, because the other possibility is two separate many-to-one relationships using each key separately.

        However, there currently is no declaration that would allow you to tell the system that the two FKs are to be used in tandem, so to implement your use case, you need to override getExpansionComponent() and provide your own ListGrid which you can call fetchData() on, passing both keys in criteria.

        Comment

        Working...
        X