Discussion:
Addtion of columns to a grid in an open form
(too old to reply)
sm k
2011-04-21 09:51:22 UTC
Permalink
There is a form with mix of controls including a grid control. On the click of the button, i need to delete the existing grid and build a new grid with new columns without closing the form.

I am able to add a grid control and run as new instance of the existing form.

Could anyone suggest to refresh/ rebuild the grid in the same instance of the form and not as a new instance.

Sample Code:

void CreateGrid(Args _args, str _formname)
{
Form form;
FormBuildDesign design;
FormBuildDataSource ds;
FormBuildGridControl grid;

Args args;
FormRun formRun;
;

form = new Form(_formname,false);//formstr("AddGridForm"));
ds = form.dataSource(1);
form.dataSource(1).table();
ds.table(form.dataSource(1).table());

design = form.design();

grid = design.addControl(FormControlType::Grid, "Grid1");
grid.dataSource(ds.id());
grid.widthMode(FormWidth::ColumnWidth);
grid.heightMode(FormHeight::ColumnHeight);
grid.addDataField(ds.id(),fieldnum(InventTable,ItemId));
grid.addDataField(ds.id(),fieldnum(InventTable, ItemGroupId));

args = new Args();
args.object(form);
formRun = new formrun(args);
formrun.init();
formrun.run();
formrun.detach();

}
sm k
2011-04-21 10:07:11 UTC
Permalink
In Dynamics Ax 2009, there is a form with mix of controls including a grid control. On the click of the button, i need to delete the existing grid and build a new grid with new columns without closing the form.

I am able to add a grid control and run as new instance of the existing form.

Could anyone suggest to refresh/ rebuild the grid in the same instance of the form and not as a new instance.

Sample Code:

void CreateGrid(Args _args, str _formname)
{
Form form;
FormBuildDesign design;
FormBuildDataSource ds;
FormBuildGridControl grid;

Args args;
FormRun formRun;
;

form = new Form(_formname,false);//formstr("AddGridForm"));
ds = form.dataSource(1);
form.dataSource(1).table();
ds.table(form.dataSource(1).table());

design = form.design();

grid = design.addControl(FormControlType::Grid, "Grid1");
grid.dataSource(ds.id());
grid.widthMode(FormWidth::ColumnWidth);
grid.heightMode(FormHeight::ColumnHeight);
grid.addDataField(ds.id(),fieldnum(InventTable,ItemId));
grid.addDataField(ds.id(),fieldnum(InventTable, ItemGroupId));

args = new Args();
args.object(form);
formRun = new formrun(args);
formrun.init();
formrun.run();
formrun.detach();

}

Loading...