iwadvdbgrid image column

Hi, how put an image that it is not in a dataset into an image column?

Hi,


You can add a Column of Type ctImage, then use the OnGetCellData event to set the cell value.

Example:
procedure TformDBGrid.TIWDBAdvWebGrid1GetCellData(Sender: TObject; RowIndex,
  ColumnIndex: Integer; var AValue: string);
begin
  if ColumnIndex = 0 then
    AValue := 'image.png';
end;

Thank you. sorry for posted twice

Hi, still not working.
this is de column definition:
Columns = <
          item
            CheckTrue = 'true'
            CheckFalse = 'false'
            ColumnHeaderFont.Color = clNone
            ColumnHeaderFont.Size = 10
            ColumnHeaderFont.Style = []
            ColumnType = ctImage
            DefaultDynEdit = '0'
            DefaultDynText = '0'
            DetailFont.Color = clNone
            DetailFont.Size = 10
            DetailFont.Style = []
            ImageIndex = 0
            Font.Color = clNone
            Font.Size = 10
            Font.Style = []
            FooterFormat = '%g'
            Name = 'EDIT'
            SpinEditMaxValue = 100
            SpinEditMinValue = 0
            Width = 32
          end
and this is the code:
procedure TFStampeSLP.grdElencoGetCellData(Sender: TObject; RowIndex, ColumnIndex: Integer; var AValue: string);
var ImagesPath: string;
begin

//  ImagesPath := TPath.combine(WebApplication.ApplicationPath, 'Immagini');
  ImagesPath := 'Immagini';
  if ColumnIndex = 0 then
    if dsDocuments.DataSet.FieldByName('DATA_LETTURA').IsNull and dsDocuments.DataSet.FieldByName('DATA_STAMPA').IsNull
    then
      AValue := TPath.Combine(ImagesPath,'flag_mark_red.png')
    else
      AValue := TPath.Combine(ImagesPath,'flag_mark_green.png');
end;

and this is the result in the grid


Other question could be possible to load the png image from an IWImageList? and if yes how?
  • Can you please make sure the path to the image is correct?
    By default an IntraWeb application expects the files to be inside a subfolder of the application called "wwwroot".
    - You can assign a TIWImageList to the Images property, the set the Columns.ImageIndex property to the desired image index.

Yes, I have already checked the path that seems to be correct

We are not aware of any issues with displaying an image in a Column of ColumnType ctImage.
Can you please check in the browser's page source if the correct path has been added in the cell as expected?


If the problem persists, please provide the following information so I can further investigate this:
- The version of Delphi you are using
- The version of IntraWeb you are using
- The name and version of the browser you are using
- A ready to run sample project that demonstrates the issue
You are right, putting the image folder under wwwroot is working as expected.
Thank you.

Thank you for notifying this was resolved.

now
another problem occurs, when I click on a grid row after the
grdElencoAsyncRowSelect detected seems that the GetCellData event is not
executed and so the column loose the images

I have not been able to reproduce this, please provide the following information so I can further investigate this:
- The version of Delphi you are using
- The version of IntraWeb you are using
- The name and version of the browser you are using
- A ready to run sample project that demonstrates the issue
RadStudio XE7 using Delphi
Intraweb 15.0.17
Firefox Quantum 66.0.5.

Please Tell me how can I send you the sample project

You can send the sample project by email to: mailto:help@tmssoftware.com

Hi, if I reload the page with F5 key, then the images are shown correctly

Hi,


Can you please try changing your code as indicated below?<o:p></o:p>

 

procedure TFStampeSLP.grdElencoGetCellData(Sender: TObject; RowIndex, ColumnIndex: Integer; var AValue: string);

var

  ImagesPath: string;

begin

  ImagesPath := 'Immagini';

  if ColumnIndex = 0 then

    if dsDocuments.DataSet.FieldByName('DATA_LETTURA').IsNull and dsDocuments.DataSet.FieldByName('DATA_STAMPA').IsNull

    then

      AValue := ImagesPath + '/flag_mark_red.png'

    else

      AValue := ImagesPath + '/flag_mark_green.png';

end;