|
28.10.2006, 19:01 | #1 |
Участник
|
Dave: Creating Header/Detail-based Linkage On One Form
Источник: http://daxdave.blogspot.com/2006/10/...inkage-on.html
============== I have been struggling with a seemingly simple concept over the past couple days: How to setup a form that has two grids where one grid represents header-level data and the other grid represents detail-level data with the proper linkage. In all of the books, newsgroups, and blogs out there no one has yet to tackle documenting this seemingly simple task until now. I managed to get the form running tonight and I am posting this in case someone else may be struggling just like I have been. In my struggles I tried to mimic both the architecture and properties of both the SalesTable and SysEmailTable forms which have Header and Detail grids. Even after duplicating what these two forms use, my form still did not work properly. In all cases my detail form showed all records no matter which header record I placed focus on. Below is the steps that I have verified that successfully develops a header and detail grid. There may be other ways to accomplish this but this process definitely works. 1.) SETUP THE DATABASES: If you have not already, create your header records table and your detail records table. a. Creation of your tables should include adding the appropriate Extended Data Types to your table for the fields you would like it to have. b. Your Detail table should include the field that is in your Header table that you wish to use as the key between the two tables. c. Add Indexes to both tables while including the key to your header table in the index along with including the same field that is in your Detail table as part of the index. d. Add a relation to the Detail table to join the fields that appear in both the Header and Detail tables together. e. If you wish to prevent database anomalies, add a DeleteAction to the Header table that performs a 'Cascade' DeleteAction on the Detail table. 2.) LINK DATABASES TO FORM: Drag the Header and Detail table into the Data Sources node of the Form you wish to use to display the two. a. Set the Detail table's properties JoinSource property to the name of the Header table and verify the LinkType is set to Delayed. b. If you do not want AX to automatically add a new record if no records exist, set InsertIfEmpty to 'No' in the Data Source properties of the Detail and/or Header data sources. 3.) DESIGN FORM FROM DATABASES: Add the appropriate container hierarchy to your form design and add the appropriate fields to each. a. In my form, I created three groups within the form: Header, ControlSplit, and Detail. b. The Header Group contains a Tab, within the Tab a TabPage, and within the TabPage a Grid control. The Grid control's datasource property is set to the Header table. c. The Detail Group contains a grid control with the datasource property set to the Detail table. d. Within the Header and Detail Group's grid, I dragged the appropriate fields/field groups into their respective grids. Using these steps you should be able to correctly link Header Table data within a form to Detail Table data where only Detail Table data is displayed based upon the current Header Table data record. I hope this helps those of you who maybe new to AX like myself and are struggling with a similar problem. ============== Источник: http://daxdave.blogspot.com/2006/10/...inkage-on.html |
|
|
|