grid etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
grid etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

5 Şubat 2016 Cuma

AXAPTA - Prevent user to change filter from grid header

SysQuery::findOrCreateRange(InventDim_DS.query().dataSourceTable(tablenum(InventDim)),fieldnum(InventDim,InventSiteId)).status(RangeStatus::Locked);

22 Ocak 2016 Cuma

Axapta - Why sometimes MultiSelectionHelper and why sometimes traditional read?

That's the  traditional way to read selected records from a grid:

 c = CustTable_DS.getFirst(true);
 while (c.RecId != 0)
 {
      info(c.Name);
      c = CustTable_DS.getNext();
 }


But there's a problem with this way. If user just wants to process records at line instead of select a couple of records unfortunately that record will be missed. That's the workaround for this symptom:


c = CustTable_DS.getFirst(true);
noSelected = true;
while (c.RecId != 0)
{
     noSelected = false;
     info(c.Name);
     c = CustTable_DS.getNext();

}
if  (noSelected)
    info(CustTable.Name);

MultiSelectionHelper solves this problem:

 MultiSelectionHelper helper = MultiSelectionHelper::construct();
CustTable c;
;

helper.parmDatasource(CustTable_ds);

c = helper.getFirst();
while (c.RecId != 0)
{
      info(c.Name);
      c = helper.getNext();

}


But there is a disadvantage for MultiSelectionHelper class too. If user wants to sort records at grid and wants to process with this sorted list we have to use traditional way again  because unfortunately MultiSelectionHelper doesn't care about users sort.

Using MultiselectionHelper from a class:

public static void main(Args _args)
{
    SMAServiceOrderTable    serviceOrder;
    MultiSelectionHelper    helper;
    FormRun                 caller = _args.caller();
    FormDataSource          SMAServiceOrderTable_DS;
  
    SMAServiceOrderTable_DS = caller.dataSource();
    helper = MultiSelectionHelper::createFromCaller(caller);
    helper.createQueryRanges(SMAServiceOrderTable_DS.queryBuildDataSource(),fieldStr(SMAServiceOrderTable,RecId));
    
    serviceOrder = helper.getFirst();
    
    while(serviceOrder)
    {
        info(strFmt("%1",serviceOrder.RecId));
        serviceOrder = helper.getNext();
    }
}

30 Haziran 2015 Salı

Axapta - Show image at grid column

In the sample we will use RefRecId field; show OK image when filled, show Cancel image when empty. For this, we write a display method to the table (or table data source of course):

 display ImageRes dispIsOKImg(gzrForeSightOrderLines l)
 {
   #resAppl;
   return l.RefRecId == 0 ? #ImageError : #Image_OK;
 }


Add a Window control to grid. At this sample it's name is LineOK. Make AlignControl of control to No. Write display method's name (for this sample is dispIsOKImg) to DataMethod, write table name (gzrForeSightOrderLines for this sample) to Datasource. Write suitable values to Height and Width. I wrote 14 both of them. If your image is so big you make ImageMode value as  Size to fit.

You will see pictures periodically refresh when run the form. For prevent this effect, you have to load images at form init:

ClassDeclaration method:
ImageList                           imageList;

Init method:
#resAppl
imageList = new Imagelist(Imagelist::smalliconWidth(),Imagelist::smalliconHeight());
imagelist.add(new image(#Image_OK));
imagelist.add(new image(#ImageError));
LineOK.imageList(imageList);


change return line like this at the Display method:

return l.RefRecId == 0 ? 1 : 0;

To see/update image list at resAppl macro:

AOT->Macros->ResAppl->Edit

To see all image resources at the system Tools->Development tools-> Embedded resources.