Friday, 2 May 2014

Showing Bitmap flags in the Repeater (!!! Without Add-ins !!!)

I have heard this a number of times: 

"How do I show Bitmaps in a RTC Repeater?" This seems not to work – so can you please make Add-ins work in the Repeater too (so we can make a Picture Add-in for the repeater)?

Therefore I'd like to post a clarification in this Blog (even if this Post then is not about Add-ins).

The RTC can actually show pictures in the repeater, and even many more formats than the classic client! Png with transparency, Gif, Jpg, ...

And this screenshot proofs it:


This is how you do it:

In the table which the page is bound to, add a field of type BLOB and Subtype Bitmap. Any field on the page that is bound to that field will happily show any picture that is stored in this table field.
"This is not the problem(!)", you might say – Yes, I know icon_wink

You then probably want to show a picture based on an expression for a value column in a data table. Of course the pictures shall come from a different table, that contains all possible state pictures in your application. Actually, something like in the screenshot above. This what others often say is a “KPI”.

icon_cry  The bad news :
There is a known bug in NAV 2009 and also SP1, that prevents that Bitmaps are retrieved for a SourceExpression to another table than the table than the page is bound to.

icon_smile  The (little) good news:
You can work around it. You may maintain all state pictures in a separate bitmap table. But you also need to add a Bitmap BLOB field to the data table that you bind the page with the list to. Now you copy the respective state Bitmap over, from the Bitmap table to the data table. You can do this in the Triggers OnAfterGetRecord() and OnModifyRecord(), the latter if your list is editable.

To keep performace up, you might want to cache the records for the needed state images in variables on the page, so you do not need to search for the respective state picture in your bitmap table over and over again (will probably not be a big issue in many scenarios though).

And another interesting aspect: We clearly do not want state pictures to end up in the value table in the database. For tables with large amounts of rows this increases the database size unnecessary. Therefore we cater in the OnModify and OnInsert trigger of the value table that the picture field gets cleared.

You will find some sample objects attached to this post.


No comments:

Post a Comment