Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    getDisplayValue() is not being called

    SmartClient : Smartclient v8.2p_2012-06-07 - Power Edition
    Browser : IE 9

    I'm adding this to a ribbon:
    Code:
    	title: 'Sectors',
    	numRows: 2,
    	width: 220,
    	height: 89,
    	searchPanelRef: this,
    	isRequired: false,
            showDefaultValue: false,
    	ID: 'SectorMultiSelect',
    	numCols: 2,
    	titleOrientation: 'top',
    	name: 'sector', 
    	editorType: 'select',
    	multiple:true,
    	multipleAppearance:"picklist",
    	optionDataSource: "coolSectors",
    	showTitle: false,
    	displayField:"name",
    	valueField:"id",
    	getDisplayValue: function(value) 
            {
    	        if (value != null && value.length > 1) 
    	        	return '...';
    	        return value;
    	}
    The function getDisplayValue(value) is not getting called.

    #2
    That's correct - the docs do not tell you this is an override point where you should expect to be called at specific times (be sure to read the docs).

    See formatValue and related APIs for controlling formatting.

    Comment


      #3
      the function formatValue formats ALL of the displayFields in the list, and this is not what I was wanting. I need the concatenated string of all the selected items to go to '...' after the user selects more than one option. I don't think I was clear on my original question.

      Comment


        #4
        It's not exactly a normal usage, but you could achieve this by applying custom pickListFields.
        By default the "formatValue" formatter will be applied to the automatically generated pickListField, and thus will apply to the items in the drop-down pickList. You can bypass this with an explicitly defined pickListFields object - something like this:
        Code:
                {
                    type:"select",
                    title:"Select Multiple (PickList)",
                    multiple:true,
                    pickListFields:[
                       {name:"name"}
                    ],
                    formatValue:function (value, record, form, item) {
                        // ... custom code here
                    },
                    multipleAppearance:"picklist",
                    valueMap: [ "Cat", "Dog", "Giraffe", "Goat", "Marmoset", "Mouse" ]
                },
        Obviously if you're using an optionDataSource, you'll tweak the name of the pickListField.
        In 8.2, the value passed to the formatValue function is the formatted string, so you'll get a comma-separated string rather than an array when multiple items are picked. Your detection code will have to catch that and behave accordingly.

        Regards
        Isomorphic Software

        Comment


          #5
          I can't change the pick list. The items in the list need to remain the same it is the string value in the dropdown box needs show the selected item if only 1 and "..." if more are selected.

          Comment


            #6
            If we understand you correctly, you're looking for this:
            - the drop-down list of items (the pickList) shows normal entries for each selectable item
            - the actual static text indicating what is currently selected will show the value (as it normally would) if a single entry is selected, otherwise "..."

            The code snippet above allows you to do this.

            Please let us know if we're misunderstanding your requirements or need further assistance.

            Comment

            Working...
            X