Print Page | Close Window

iwadvdbgrid image column

Printed From: TMS Software
Category: IntraWeb Components
Forum Name: IW Grids
Forum Discription:
URL: http://www.tmssoftware.com/site/forum/forum_posts.asp?TID=13454
Printed Date: 12 Dec 2019 at 5:31am


Topic: iwadvdbgrid image column
Posted By: Bordin Marco
Subject: iwadvdbgrid image column
Date Posted: 22 May 2019 at 11:49am
Hi, how put an image that it is not in a dataset into an image column?



Replies:
Posted By: Bart Holvoet
Date Posted: 22 May 2019 at 3:43pm
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;


Posted By: Bordin Marco
Date Posted: 22 May 2019 at 3:58pm
Thank you. sorry for posted twice


Posted By: Bordin Marco
Date Posted: 23 May 2019 at 11:12am
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?


Posted By: Bart Holvoet
Date Posted: 23 May 2019 at 2:38pm
- 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.


Posted By: Bordin Marco
Date Posted: 23 May 2019 at 3:51pm
Yes, I have already checked the path that seems to be correct


Posted By: Bart Holvoet
Date Posted: 23 May 2019 at 4:00pm
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


Posted By: Bordin Marco
Date Posted: 23 May 2019 at 4:44pm
You are right, putting the image folder under wwwroot is working as expected.
Thank you.


Posted By: Bart Holvoet
Date Posted: 23 May 2019 at 4:47pm
Thank you for notifying this was resolved.


Posted By: Bordin Marco
Date Posted: 23 May 2019 at 4:54pm
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


Posted By: Bart Holvoet
Date Posted: 23 May 2019 at 5:09pm
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


Posted By: Bordin Marco
Date Posted: 23 May 2019 at 5:28pm
RadStudio XE7 using Delphi
Intraweb 15.0.17
Firefox Quantum 66.0.5.

Please Tell me how can I send you the sample project


Posted By: Bart Holvoet
Date Posted: 24 May 2019 at 8:46am
You can send the sample project by email to:  mailto:help@tmssoftware.com - mailto:help@tmssoftware.com



Posted By: Bordin Marco
Date Posted: 16 Jul 2019 at 7:15pm
Hi, if I reload the page with F5 key, then the images are shown correctly


Posted By: Bart Holvoet
Date Posted: 17 Jul 2019 at 8:32am
Hi,

Can you please try changing your code as indicated below?

 

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;





Print Page | Close Window