Announcement

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

    Adding a row to the data in the transformResponse function

    Hi,
    I am getting using the optionDataSource property for the select box to populate the data in my dynamic form. In the datasource creation I am trying to add a row to the returned and set it back to the dsResponse.data but it doesnt seem to change the size of the array. The item is added but as a result the last item is deleted. Please let us know whether anything like this can be done.
    Code:
    isc.DataSource.create({
    	ID:"sourceOptDS",
    	serviceNamespace :"http://myservice.abc.com/",		
    	wsOperation : "getSrcSystems",
    	recordName : "sourceSystem",	
    	autoFetchData: false,
    	fields:[
    		 {name:"sourceSystemId"},
                               {name:"sourceSystemName" }
    		
    	],
    				
    	transformResponse : function (dsResponse, dsRequest, xmlData) {
    	    if (dsRequest.operationType == "fetch") {
    			showFault(xmlData);
    			var temp =new Array(dsResponse.totalRows+1);
    			temp[0] = {sourceSystemId:"-1", sourceSystemName:"ALL"};
    			for (var i=0; i<dsResponse.totalRows ; i++)
    			{
    				temp[i+1]={sourceSystemId:dsResponse.data[i].sourceSystemId, 
    					sourceSystemName:dsResponse.data[i].sourceSystemName};	
    							}
    			dsResponse.data = temp;
    			alert('size'+dsResponse.totalRows);
    		}
    		return dsResponse;
    	}
    	
    
    });

    #2
    Set dsResponse.endRow and possibly dsResponse.totalRows to reflect the increased number of rows you are now returning.

    Comment


      #3
      Hi,
      Found the solution, i specified both the optionDataSource and valueMap with the new values in my select box definition, it worked.
      I have still one doubt though, the above question that i had posted worked fine for multiple select but not for single select.
      The solution i found works only for single select and not for multiple select.

      Please guide what could be the reason and logic behind it.
      Code:
      isc.DynamicForm.create({
          fields:[
      	{name:"sourceId", title:"System" , type:"select" ,optionDataSource:"sourceOptDS",displayField :"sourceSystemName",valueField:"sourceSystemId",defaultValue:"-1", valueMap: {"-1" : "ALL"}}]
      ,
          autoDraw:false,
          ID:"srcSearchForm"
      })

      Comment


        #4
        See previous response, however, note further that there is special support for allowEmptyValue in SelectItems that you can use for your "All" option without having to write a transformResponse().

        Comment

        Working...
        X