Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 10 of 11 total |
Color Last Row In Grid |
Tue, Dec 1 2015 10:01 AM | Permanent Link |
squiffy Telemix Ltd. | I'm trying to set the background colour of the last row in a grid, just after I load the data from a json return string.
Do I have to go through each cell individually or is there a way to set a row's background (and foreground) colours? |
Tue, Dec 1 2015 12:47 PM | Permanent Link |
Walter Matte Tactical Business Corporation | Yes - each cell.
Walter |
Tue, Dec 1 2015 5:00 PM | Permanent Link |
squiffy Telemix Ltd. | >> Walter Matte wrote:
>> Yes - each cell. At the moment I'm looking for a keyword in the returned json ("total") and setting a var to indicate that all cells from now on should have the new background/font colours. Just wondering if anyone has a more elegant solution than this? I want to go to the last row of cells after everything is loaded and set the background/font colours. My way works but it's very fragile. |
Wed, Dec 2 2015 12:39 AM | Permanent Link |
Richard Harding Wise Nutrition Coaching | <<
At the moment I'm looking for a keyword in the returned json ("total") and setting a var to indicate that all cells from now on should have the new background/font colours. Just wondering if anyone has a more elegant solution than this? I want to go to the last row of cells after everything is loaded and set the background/font colours. >> I wondered how you did it. As far as I can see, there as not an alternative at the moment. In July 2013, Tim wrote in response to Mathew Jones's question in the topic Grid Customisation that it was not possible to do so on "a per-row basis." It is something that I would like to see too. I think it would be really useful unless someone can assist with another way. Richard Harding |
Wed, Dec 2 2015 4:21 AM | Permanent Link |
squiffy Telemix Ltd. | Richard -
this is what I did. It's horrible but it works for me. I create a global vars : var statsTotal : Boolean = False; // True if on the final "totals" line. totalBackColour : TColor = clDarkGray; // colour for totals line. totalFontColour : TColor = clWhite; // forecolour for totals line. The CellUpdate event is used to look for data in the first column that reads "Total". If found then set the global to True so other cells can colour accordingly : procedure TfrmStats.statscolCategoryCellUpdate(Sender: TObject; ACell: TGridCell); begin if ACell.Data = 'Totals' then statsTotal:=True else statsTotal:=False; if statsTotal = True then begin ACell.Background.Fill.Color:=totalBackColour; ACell.Font.Color:=totalFontColour; end; end; All the other columns just have this : procedure TfrmStats.statscolACDCellUpdate(Sender: TObject; ACell: TGridCell); begin if statsTotal = True then begin ACell.Background.Fill.Color:=totalBackColour; ACell.Font.Color:=totalFontColour; end; end; Like I say, not pretty and very fragile, but it works for me. |
Wed, Dec 2 2015 12:05 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | << I'm trying to set the background colour of the last row in a grid, just after I load the data from a json return string.
Do I have to go through each cell individually or is there a way to set a row's background (and foreground) colours? >> The issue is the inability to attach data to a specific un-bound row. I think this is already on the list, but I'll add it, if it isn't. Once you can attach data to a specific row, then you can just examine that data in the OnCellUpdate to determine how to style the cells in that row (by using the grid's RowOffset property combined with the cell's Index property). Tim Young Elevate Software www.elevatesoft.com |
Wed, Dec 2 2015 1:40 PM | Permanent Link |
squiffy Telemix Ltd. | Tim -
not sure if this makes any difference, but my grid is data bound. Once it's loaded all the data I really only want to go to the last row and format all those cells. The number of rows is indeterminate. Testing the data for a keyword like I'm doing is error prone (the server may change the wording for instance) Cheers, |
Wed, Dec 2 2015 3:21 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | << not sure if this makes any difference, but my grid is data bound. Once it's loaded all the data I really only want to go to the last row and format all those cells. The number of rows is indeterminate. >> Sorry, your previous post about loading the data from JSON gave me the impression that you were loading the grid rows directly from JSON. As for the above, you have to keep in mind that an EWB grid is virtual. There is no "last row" in terms of the cells and how they are drawn, so you can't really "go to the last row and format those cells". The same cells used for the last row are *also* used for other rows as the underlying rows are navigated in the grid. With or without a dataset, determining whether you're on the last row in an OnCellUpdate event handler is a simple calculation: IsLastRow:=((MyGrid.RowOffset+ACell.Index)=MyGrid.RowCount); Tim Young Elevate Software www.elevatesoft.com |
Wed, Dec 2 2015 5:17 PM | Permanent Link |
squiffy Telemix Ltd. | >>Tim Young [Elevate Software] wrote:
>>Sorry, your previous post about loading the data from JSON ... Ah sorry. I meant to say dataset is loaded, not data. The json is loaded into the dataset and the grid is bound to that. Ok, a couple of modifications to your example and I now have this which works : if (statsGrid.RowOffset+ACell.Index)=(dsStats.RowCount-1) then ACell.Font.Color:=clBlue; First observation is that unless I set statsGrid.RowIndex:=-1 then the first row is also affected by the above code. What is odd is that I log the values of both sides of the IF equation and they only ever match once for the final line. I probably need to dig deeper on that but it doesn't matter as setting the RowIndex is desirable anyway. Second is that the CellUpdate seems to fire on mouse over events as well as the data actually updating. Is this by design? It results is a lot of unnecessary (in my opinion) events firing, though it does remove the first line formatting as per my first observation if I don't set the RowIndex. |
Wed, Dec 2 2015 7:41 PM | Permanent Link |
Raul Team Elevate | On 12/2/2015 5:17 PM, squiffy wrote:
> Second is that the CellUpdate seems to fire on mouse over events as well as the data actually updating. Is this by design? OnCellUpdate is not just for data updates but also for appearance updates. It would need to fire like this to do mouse hot tracking or cell (row)selection etc. Raul |
Page 1 of 2 | Next Page » | |
Jump to Page: 1 2 |
This web page was last updated on Friday, November 1, 2024 at 07:01 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |