Monday, November 14, 2011

Axapta disable specify column in Grid

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);
}





Axapta basic calling method knowledge

Would like to share few basic calling method knowledge here..

Way to call a Form's method (methodX) : element.methodX 

Way to call Data Source(vendTable)'s method(methodY) : vendTable_ds.methodY

Way to call Table(vendTable) method(methodZ) : vendTable.methodZ 

Way to call a Static method(methodA) in table(vendTable) : vendTable::methodA