Go Back   SmartClient Forums > Technical Q&A
Wiki Register Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 7th Aug 2008, 10:43
sharmamo sharmamo is offline
Registered Developer
 
Join Date: Jul 2008
Posts: 18
Default 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;
	}
	

});
Reply With Quote
  #2  
Old 7th Aug 2008, 11:45
Isomorphic Isomorphic is offline
Administrator
 
Join Date: May 2006
Posts: 30,615
Default

Set dsResponse.endRow and possibly dsResponse.totalRows to reflect the increased number of rows you are now returning.
Reply With Quote
  #3  
Old 7th Aug 2008, 11:47
sharmamo sharmamo is offline
Registered Developer
 
Join Date: Jul 2008
Posts: 18
Default

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"
})
Reply With Quote
  #4  
Old 7th Aug 2008, 11:51
Isomorphic Isomorphic is offline
Administrator
 
Join Date: May 2006
Posts: 30,615
Default

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().
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search


© 2010,2011 Isomorphic Software. All Rights Reserved