This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
I have been trying to add a Material Design Icon to a Data Table but it does not seem to be allowed. The Data Table that can be dragged from the Material Design Controls looks to be the older version List View.
EDIT: Figured out some things after some more tests and am now down to two options.
Create multiple RPs that contain just a Material Design Icon
Stick to using Bitmaps
If anyone has any other ideas on how to implement this please let me know. I am inclined towards Option 1 if there is no other alternatives available.
define_com class(#MGSIconListDesignPanel) name(#lIcon) reference(*DYNAMIC)
* ......
add_entry to_list(#DataList)
* these have to come AFTER the data is added to the list because we can only get to them through the CURRENTITEM property
#DataList.CurrentItem.RelatedReference <= #DataItem
* Companionated
if (#lItem.CompanionNumber <> 0)
#lIcon <= #ColumnMGSAPPP011.CurrentItem.Part *As #MGSIconListDesignPanel
#lIcon.Icon := "copyright"
endif
* Menu
#lIcon <= #ColumnMGSAPPP012.CurrentItem.Part *As #MGSIconListDesignPanel
#lIcon.Icon := "menu"
endif
I had tried to implement it similarly yesterday but the problem was I was using *ListFields on the RP. Dragging it to the list for multiple columns ended up with the compile getting an error which makes sense as it was like dragging the same field over the list multiple times.
I am now trying to open separate Dialogs when each of the Material Design Icon RPs are clicked. The icons are defined in the same way as @jyoung suggested (many thanks for that).
This RP column however, only has a "ColumnClick" Event. What would be the best way to be able to differentiate through these icons' click events without making it too complicated?
Once again, there may be better way to handle this, but this seems to work.
You are right, the problem, is that Part Columns do not have a click event, however the part itself does. This of course means we have to get a reference to the part. You do this by grabbing the part when the item gets focus in the list. Dealing with multiple parts is simply a matter of having another reference. Then handling the click event is a simple event handler.
EPC140230 introduces two new column classes on PRIM_LIST, PRIM_LIST.Icon / #PRIM_LIST.Label, which are basically the list-version of PRIM_MD.Icon/PRIM_MD.Label.
So now you don't have to introduce a reusable part for the Material Design icon anymore... copy the code below into a Web Page for a sample:
As a another alternative to this - I created a PRIM_OBJT component to act as a generic conduit for any extra, custom events which a cell design column component in a list might generate. I had a situation where the row design was visually complex and where the cell design needed to fire multiple events up to the parent in different situations.
The conduit component contained a method with 2 parms (event type and a key) and an event, passing out the same 2 parms.
The conduit component was then included in the parent view/dialog/panel and after a row was ADD_ENTRY'd to the list I set the relatedreference of currentitem to be the conduit component. Then in the cell design I picked up and retained the related reference in the OnItemGotReference method.
With the infrastructure defined, when I wanted to fire a custom event from the cell design component I simply ran the conduit's method passing the event name and the key of the item effected. The conduit component receives this and immediately fires its event to the parent where a normal EVTROUTINE picks up the conduit's generic "custom event has been fired" event and then grabs the specific custom event name and key from the parms and then performs any logic as required.
Obviously this only applies if you're not already using relatedreference for some other reason, but I just thought I'd post this as an alternative that I've used.