Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Change Cell color at runtime


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 6 - Last Post: Apr 3, 2017 10:54 AM Last Post By: Dan Barclay
Carlos Matos

Posts: 114
Registered: 6/25/01
Change Cell color at runtime  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 29, 2017 3:54 AM
On an ealier version of Intraweb (I don't remenber what version), I had this to change at runtime the color of a Cell based on a condition on the IWDBGridRenderCell event:

ACell.Css := 'Grid';
if ( AColumn = 1 ) and ( Pos('Comograma', ACell.Text) <> 0 ) then
begin
ACell.Css := 'GridTexthighlighted';
end;

and this worked.
Now, after upgrading to v14.1.8, this do not work anymore. What changed? How can I accomplish this?
Carlos Matos

Posts: 114
Registered: 6/25/01
Re: Change Cell color at runtime  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 31, 2017 4:36 AM   in response to: Carlos Matos in response to: Carlos Matos
Anyone please!!!!!!!!!
Eitan Arbel

Posts: 508
Registered: 2/24/13
Re: Change Cell color at runtime  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 31, 2017 5:58 AM   in response to: Carlos Matos in response to: Carlos Matos
sorry, i don't know much about js, css etc', but maybe for now you can just set different color and style to the font of the cell (until someone from AToZed will help or update IW)
Giorgio Calzolato

Posts: 22
Registered: 7/4/02
Re: Change Cell color at runtime  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 31, 2017 1:49 PM   in response to: Carlos Matos in response to: Carlos Matos
In similar issue usually I do this:
1) Using the browser debug tool find the cell, in html format. So you can see how it is rendered by IW. This can help you in adjusting code in your Delphi TIWForm.
2) If you cannot find a solution in TIWForm, you can write JS code in you page (the html page if you use a template, or in ExtraHeader property), similar like this:

    <script>
    $(document).ready(function() {
      $('.youClass').css('background-color','green');
    });
    </script>


You can find lot of example about how to find elements in html page and how to change their properties.
Dan Barclay

Posts: 889
Registered: 11/9/03
Re: Change Cell color at runtime  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 1, 2017 12:01 AM   in response to: Carlos Matos in response to: Carlos Matos
Carlos Matos wrote:
On an ealier version of Intraweb (I don't remenber what version), I had this to change at runtime the color of a Cell based on a condition on the IWDBGridRenderCell event:

ACell.Css := 'Grid';
if ( AColumn = 1 ) and ( Pos('Comograma', ACell.Text) <> 0 ) then
begin
ACell.Css := 'GridTexthighlighted';
end;

and this worked.
Now, after upgrading to v14.1.8, this do not work anymore. What changed? How can I accomplish this?

I set the .css value and use it for similar purposes in version 14 so that should still work fine (I'm not familiar with earlier versions).

I'd first try to determine where the problem lives. Is the 'GridTexthighlighted' being rendered to the "class" of the cell element? Check the HTML content in the browser.

If it is being rendered, then you can track your css definitions to find out why the color is not responding. If it is NOT being rendered, then you can look back into your IW code to determine why. There could be something going on with the grid or cell, but before I went into that I'd find out if that is where the problem lives.

I'd find out which direction to look as a first step.

Dan
Carlos Matos

Posts: 114
Registered: 6/25/01
Re: Change Cell color at runtime  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 3, 2017 6:44 AM   in response to: Carlos Matos in response to: Carlos Matos
Something was changed on this recent version.

If I set .css property like this:
ACell.Css := 'GridTexthighlighted {}';

Instead of:
ACell.Css := 'GridTexthighlighted';

It works. Strange but this used to work on earlier version.
Dan Barclay

Posts: 889
Registered: 11/9/03
Re: Change Cell color at runtime  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 3, 2017 10:54 AM   in response to: Carlos Matos in response to: Carlos Matos
Carlos Matos wrote:
Something was changed on this recent version.

If I set .css property like this:
ACell.Css := 'GridTexthighlighted {}';

Instead of:
ACell.Css := 'GridTexthighlighted';

It works. Strange but this used to work on earlier version.

Mine works without the braces, but I am on 14.1.5

I will install the latest when I get time and try it again.

Dan
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02