In Axapta, we have the function call AllowEdit to enable or disable the grid being edit. But if we want apply some rules on the grid and only allow user edit the row that fulfill the rules, then we need to apply the code as below:-
if(Table.TableField== Enum::Value)
{
DataSource.object(fieldNum(Table,TableField1)).AllowEdit(true);
DataSource.object(fieldNum(Table,TableField2)).AllowEdit(true);
}
else
{
DataSource.object(fieldNum(Table, TableField1)).AllowEdit(false);
DataSource.object(fieldNum(Table,TableField2)).AllowEdit(false);
}
Example :-
For above grid, I would like to allow user edit the open season date and close season date when the season status is New, hence the code will as below :-
if(AvZoneMasterSeason.AvSeasonStatus == AvSeasonStatus::New)
{
AvZoneMasterSeason_ds.object(fieldNum(AvZoneMasterSeason,AvSeasonStartDate)).AllowEdit(true);
AvZoneMasterSeason_ds.object(fieldNum(AvZoneMasterSeason,AvSeasonCloseDate)).AllowEdit(true);
}
else
{ AvZoneMasterSeason_ds.object(fieldNum(AvZoneMasterSeason,AvSeasonStartDate)).AllowEdit(false);
AvZoneMasterSeason_ds.object(fieldNum(AvZoneMasterSeason, AvSeasonCloseDate)).AllowEdit(false);
}
Where should this code be placed????
ReplyDeleteIn Form > Data Source > Active method
Delete