How to display Images/Icons for grid data from resource/path in Ax

ImageList

 

void run()
{
Imagelist list = new Imagelist( Imagelist::smallIconWidth(), Imagelist::smallIconHeight());
FormWindowControl w = element.control( control::window);
Image image = new Image();
;
/*
list.add( new Image(927));
list.add( new Image(928));
list.add( new Image(929));
*/
image.loadImage(“F:\\JKG\\Johnkrish.jpg”);
list.add(image);
image.loadImage(“F:\\JKG\\Remove.png”);
list.add(image);
w.imageList( list );

super();

}

display int imageIdx(Bill_Table t)
{
if(t.Price <= 50)
return 0;
else
return 1;
}

list

Store and retrive image from Table to file in Ax 2009 & 2012

tbltoimage

JohnkrishImageTable has two fields

1. Name

2. Image ( Container and ExtendtedDataType=Bitmap)

Insert Image

static void JohnkrishImageJob(Args _args)
{
Bindata binData = new BinData();
FilePath _path;
JohnkrishImageTable _ImageStore;

;
_path = “F:\\JKG\\Johnkrish.jpg”; // file path
binData.loadFile(_path);

// select _ImageStore where _ImageStore.Name==”John”;
_ImageStore.Image = binData.getData();
_ImageStore.doInsert();

}

Retrive Image

static void TableImageToImageFile(Args _args)
{
bindata bin = new bindata();
str content;
container image;
JohnkrishImageTable jkit;
;

select jkit where jkit.Name==”John”;
image = jkit.Image;
bin.setData(image);
// Create the base64 encoded string
content=bin.base64Encode();
info(content);
// Save it to the file system as a tif format
AifUtil::saveBase64ToFile(@”F:\test.tif”, content);

}