Announcement

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

    need help with "dynamically setting valueMap for Multilpe select.

    I am creating multiple select list item. Now as per specifications, optiondataSource doesn't work with selectItem with "multiple" = true.

    So what I am doing is calling fetchData explicitely and on its call back creating an array of Object and passing it to "setValueMap()" method of the selectItem.

    I am having two separate fields for display and value.

    issue here is that after i set the Array of object with two attributes I see following in select list.
    [object][object]
    [object][object]
    [object][object]

    rather than display value only.

    here are the code details.

    Code:
    {name: "searchFieldCountry",align: "right", defaultValue: "<b>Countries</b>", type:"select",
    	            	height:54,showTitle : false,rowSpan : 3, multiple:true,
    	            	valueField:"isoCode",displayField:"name"
    },
    Dynamically create array and set value map.

    Code:
    function callBackCountryDSFetchData(data){
    	var dataArr =  new Array();
    	if(data != null && typeof data != 'undefined'){
    		//alert('here');
    		for(var k = 0; k< data.length ; k++){
    			var obj = {};
    			obj.isoCode = data[k].isoCode;
    			obj.name = data[k].name;
    			dataArr[k] = obj;
    		}
    		//alert('1');
    		myViewSearchForm1.getItem("searchFieldCountry").setValueMap(dataArr);
    	//	alert(dataArr[0].sectorItemId + '-' + dataArr[366].sectorItemName );
    	}
    }
    See attachement for the select list generated.
    Any pointers?

    Thanks
    Attached Files

    #2
    If you are not using an optionDataSource do not set displayField (you're showing whatever is in your displayField ("name") not what's in the valueMap you provided.

    If you have any further problems, be sure to post the data you're returning as well, that's critical.

    Comment


      #3
      Well I am sorry but I didn't get your point. I do need to set two values in select list valuemap. One the display field and second the value which will be returned when user selects a row. For eg. US for United States of America.

      So I will need to set both values in an object , add it to array and set it as value map. Isn't this correct?

      I am attaching the data returned from server call as JPG.

      Thanks for such quick response.
      Attached Files

      Comment


        #4
        The point is to remove the valueField and displayField settings from your code.

        Use the RPC tab to show data being delivered for your fetchData call.

        Comment


          #5
          Code:
          /isc_RPCResponseStart-->[{endRow:237,totalRows:237,isDSResponse:true,invalidateCache:false,status:0,startRow:0,data:[{isoCode:"UN",name:"UNKNOWN"},{isoCode:"AF",name:"AFGHANISTAN"},{isoCode:"AL",name:"ALBANIA"},
          . . . . . 
          . . . . . 
          {isoCode:"VI",name:"VIRGIN ISLANDS, U.S."},{isoCode:"ZW",name:"ZIMBABWE"}]}]//isc_RPCResponseEnd
          I hope you mean this data from RPCResponse tab.

          Thanks

          Comment


            #6
            but if i remove displayField and valueField settings , how will smartclient know which value to display and which value to send on form submit?

            Thanks

            Comment


              #7
              I had to go check the javadocs when I saw your post saying that a SelectItem with Multiple doesn't work with an optionDataSource. I never noticed before that it says that because I've been using several SelectItems with the Multiple option and DataSources for about 6 months. I have noticed one wierd bug with those, when I set more than 1 default value the display line shows null, null, Name of the Last Value. But the actual values returned by the SelectItem continue to be correct and SelectItems with no default value work perfectly for me every time when using an optionDataSource.

              Comment

              Working...
              X