Question

I am calling ajaxcontroller to get data from server. ajaxController.fetchCounts(callFetchcounts);

callFetchcounts, this function will be called once i got the data. I am handling it like this:

var callFetchcounts = function(data) {
if( data.length > 0){
    dwr.util.addRows("rounded-corner",[data] , cellFuncs, { escapeHtml:false });
}}

var cellFuncs = [
 function(data) {return data.category},
 function(data) {return data.count},
 function(data) {return "<a href=''>Edit</a>"}
];

From the ajaxController i will get List of objects. (I can even get array of objects.) I want to populate a table where number of rows = number of elements in the result List/array. Number of columns = number of elements in each list object. I want to populate columns with List object's data.

How to do this? I am struck here. Can any one please help me with an example.

Thanks, Tiru

Was it helpful?

OTHER TIPS

You almost accomplished you mission!
All you need to do is adjust few points on your code, check it out:

function fillTable(data) {
		if( data.length > 0){
			var cellFuncs = [
			 function(data) {return data.category},
			 function(data) {return data.count},
			 function(data) {return "<a href='#'>Edit</a>"}
			];
			
			// You don't have to use [data] if data is a list(array) of objects
			// User [data] only if data is a single object
			dwr.util.addRows("rounded-corner", data , cellFuncs, { escapeHtml:false });
		}
}

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top