0

Flex Experts,

I am a newbie here. I am trying to create a conditional tool tip for my contact detail screen. If the contact has 'special-roles' like 'ABC, XYZ' then the tool tip should appear otherwise not. We have AdvancedDataGridColumn and using dataTipFunction to display the tool tip.

I am passing, values of roles & 'special-roles' in dataProvider for all contact objects. I need to write tool-tip condition for every row(every contact). I am unable to write the condition in dataTipFunction as it has access to only 'item' object. I tried trace and Alert on 'item', but screen goes blank.

I have also tried "showDataTips" which accepts boolean but to no avail. I need a way to pass current row values (all columns) to a function from AdvancedDataGridColumn.

Here is the snapshot of my code. Any help is very much appreciated :)

<view:CopyPasteDataGrid id="contactsHolder"
                     width="100%"
                     height="100%"
                     displayDisclosureIcon="true"
                     variableRowHeight="true"
                     defaultLeafIcon="{null}"
                     folderClosedIcon="{null}"
                     folderOpenIcon="{null}"
                     useRollOver="true"
                     selectable="true"
                     styleName="PortfolioAdvanced"
                     designViewDataType="tree"
                     horizontalCenter="true"
                     verticalGridLines="false"
                     horizontalScrollPolicy="off"
                     dataProvider="{contactDetails}"
                     headerRelease="onHeaderRelease(event)">
    <view:columns>
        <mx:AdvancedDataGridColumn dataField="lastName"
                                   sortCompareFunction="lastNameCompare"
                                   headerText="{ApplicationConstants.LAST_NAME_HEADER}"
                                   showDataTips="true" dataTipFunction="buildToolTipForContact"
                                   width="100"/>
    <view:rendererProviders>
        <mx:AdvancedDataGridRendererProvider dataField="projectContacts"
                                             renderer="com.ihg.hom.common.view.components.render.ContactsRenderer"
                                             columnIndex="0"
                                             columnSpan="0"/>
    </view:rendererProviders>
</view:CopyPasteDataGrid>


private function buildToolTipForContact(item:Object):String
        {
            var myString:String="";

            return "hello";
        }
  • Don't you get your data object as item ? Then you could check if your data object contains your special roles and display a tooltip, otherwise return ""? – Philarmon May 11 '17 at 14:56
  • Whenever i access **item.something** The screen goes blank. I need current contact properties (name , roles etc) to build tool tip in buildToolTipForContact() function – ellisa khoja May 12 '17 at 08:35

1 Answers1

1

I have resolved it using different approach. I used label function. It has access to column object and based current object roles I am setting tool tip. Here is the code for reference.

    <mx:AdvancedDataGridColumn dataField="role" sortable="{isRoleSortable}"
                                       labelFunction="getRole"
                                       headerText="Role" sortCompareFunction="sortRole"   showDataTips="true" dataTipFunction="buildToolTipForContact"
                                       width="120"/> 
private var hasRole:Boolean=false;

private function getRole(item:Object):String
{
    // extra code
    if(currentRoles.indexOf(specialRole)!=-1)
    {
        hasRole=true;
    }

}
private function buildToolTipForContact(item:Object):String
            {

            var myStr:String="";
                if(hasRole){
                    myStr="Special Role";
                }

                return myStr;
            }