Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
60
Wingrid on dataset: 1 master grid, 2 detail grids based on same datatable
posted

Hi all,

imagine this scenario:

- dataset based on MSSQL database

- MSSQL tables are master 1:n detail; Foreign key is F_Master_ID

- detail table has a "side" attribute (L/R for left/right) which assigns each detail to a side.

- GUI is required to have 3 editable grids: master, "left details" and "right details", so users can edit all data.

If it was just one detail grid, I'd follow the usual master-detail approach as follows:

ugrDetail.SetDataBindings(dst.tblMaster, "FK_Master_Detail", true);

But this would show L and R details in the same grid.

In LINQ; I'd use a WHERE-clause on detailrow.Side to to separate them, but LINQ results are not editable in a Wingrid afaik. 

So, how to solve this? I'm using v20.1.

Thanks for any hint! :)

Best

Martin

  • 60
    Offline posted

    Hi all,

    this dirty trick works:

    • Added two columns in the stored procedure that fills the master datatable: "constSideL", showing a constant char value of 'L' (for left), and a corresponding constSideR giving a constant char 'R' for right.
    • Added two relations between master and detail datatables; each joining the FK (as before) AND the constSideL/R to the side field of the details. So, one relation finds the left side details for a master row, the other the right side.
    • Bound the detail grid for left side to master datatable and the datamember to FK_MasterDetail_L (or R, accordingly).
    • Works! 

    But are there other solutions?

    Thx

    Martin