getting mutliple values from listgrid and displaying as forms static text

Hi,

I have a requirement where, i can select multiple records from a listgrid and the corresponding selected records will be displayed as a form items (static text).

Its like fetching data from listgrid and displaying the same fetched data in form, but all in new line

Example: I have a listgrid with many user and i select 5 users, the corresponding value will be displayed in form as follows

User: abc
xyz
pqr
mno
stu

Can you please tell me hows that possible.

thanks,
Shyama

Just take the field values and combine them yourself. The records in a ListGrid are JavaScript Objects, the field values are ordinary properties.

Am able to get multiple values and store in a variable, but not able to refer to it.

Here is step by step method of what I did.

  1. I created a form and inside that am giving this function
isc.DynamicForm.create({ 	  
        autoDraw:false,
	width: 600, 		
       titleSuffix: ":",			
		  fields: [ 
             { title:"Name",  type:"staticText" }
   ],
setMulti: function(data){	 
	 MyForm.editRecord(data[0]);
	}
})
  1. I created a listgrid and fetching data from listgrid and displaying in form.
    when single selection is done, it works, but for multi am using the following function.
 recordSelected: function(selectedData) { 
 var mixed_data = "";
 var str = "";
 for (i=0;i<selectedData.length;i++){
 var multiData = selectedData[i].groupName;
 var GridMultiData = MyGrid.getSelection().groupName;			
 str = multiData;
 mixed_data += str+"<br><br>";
 alert("name" + mixed_data);	//am able to get all the selected data in the loop	
 alert("Function working");			 			 	 
  }
 MyForm.setMulti(mixed_data);
 }

can you please tell me what went wrong as am getting a blank form. with only the field name and no values.

You appear to be putting together a String (mixed_data) and passing it to an API that expects a JavaScript Object (editRecord()).

Ok Thanks I got it. I have made few modifications and this is what I did. But still am not getting the output.

var formdata =  new Object();  
var mixedData = "";
var str = "";
for (i=0;i<selectedData.length;i++){				 					var dataSelect = selectedData[i];		 		
str = dataSelect;
mixedData  = mixedData  + str + "<br /> <br />";
formdata.item = mixedData ; 

  Myform.editRecord(formdata);				    	 
}
Myform.markForRedraw();

if I use Myform.editRecord(str ); its able to get me only one by one value out of multi selected. Is their any way i can append this “str”

Hi Sprayaga
I’m not entirely clear on what you’re trying to achieve here, but dynamicForm.editRecord() expects to be passed an object consisting of fieldName / value pairs.
For example
var record = new Object();
record.field1 = “Value 1”;
record.field2 = “Value 2”;
myForm.editRecord(record);

Or, more succinctly:
myForm.editRecord({field1:“Value 1”, field2:“Value 2”});

The form will then display each value in the appropriate form item, determined by the ‘name’ property of the form item.
For example

isc.DynamicForm.create({
    ID:"myForm",
    items:[
        {name:"field1", title:"Field 1", type:"staticText"},
        {name:"field2", title:"Field 2", type:"text"}
    ]
})

myForm.editRecord({field1:"Value 1", field2:"Value 2"});

This would display “Value 1” in the first item, “Value 2” in the second item.
In your case the “formData” object you create has the attribute “item” set. If you have an item in your DynamicForm with name set to “item”, you should see the ‘mixedData’ string showing up in that item.

Make sense?

Thanks, I was able to get the output