MerC
MerC

Reputation: 323

Multiple tabbed grids but record info only referencing to the grid in the first tab

I've got a form done in x++ (formBuild) and I managed to display different grids in different tabs. However, when I do a right-click record info on any of the grids other than the first one, the details are that of the first grid. Eg. The second row of grid 2 when I do a record info is actually the second row of grid 1.

One thing is all the grids are actually using the same table, just having different query ranges for each.

Any way to fix this?

Added code snippets

Making the grid:

for (counter = 0; counter < locations.lastIndex(); counter++)
{
    formBuildDatasource = form.addDataSource(tableStr(SomeTable));
    formBuildTabPageControl = formBuildTabControl.addControl(FormControlType::TabPage, locations.value(counter+1));
    formBuildTabPageControl.caption(locations.value(counter+1));
    formBuildGridControl = formBuildTabPageControl.addControl(FormControlType::Grid, locations.value(counter+1));
    formBuildGridControl.allowEdit(0);
    formBuildGridControl.dataSource(formBuildDatasource);
    formBuildGridControl.height(500,-1);
    formBuildGridControl.width(550,-1);
    formBuildGridControl.addDataField(formBuildDatasource.id(), fieldNum(SomeTable, MachineId));
    formBuildGridControl.addDataField(formBuildDatasource.id(), fieldNum(SomeTable, MachineStatus));

}

Adding the query:

for (counter = 0; counter < locations.lastIndex(); counter++)
{
    fds = formRun.dataSource(counter+1);
    qbds = fds.query().dataSourceNo(1);
    qbr = Qbds.addRange(fieldnum(SomeTable, MachineLocation));
    qbr.value(locations.value(counter+1));
}

Upvotes: 0

Views: 1467

Answers (3)

Ryan George
Ryan George

Reputation: 186

You actually need to set the datasource on the grid object using the id() method on the FormDataSource object, not just the full object.

Change from:

formBuildGridControl.dataSource(formBuildDatasource);

to:

formBuildGridControl.dataSource(formBuildDatasource.id());

Upvotes: 0

Jan B. Kjeldsen
Jan B. Kjeldsen

Reputation: 18051

This answer to your prior question applies here as well:

Adding view/temporary table records to Form Grid

You will have to use more than one datasource (using the same table). Remember to change the datasource attribute of the grids to match the correct one. My guess would be that they currently all reference the same datasource.

Upvotes: 1

ian_scho
ian_scho

Reputation: 6056

Can you make a query + view of the table, and have that as the 'child' entity?

I don't know why you can't have the same table referenced twice in the same form data sources, however. Ensure that the link between the tables are defined correctly, and you have no confusion with the datasource names that you use for them.

Upvotes: 0

Related Questions