Handling java List in dwr addRows function
-
04-07-2021 - |
Pregunta
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
Solución
This should help - http://www.packtpub.com/article/dwr-java-ajax-user-interface-basic-elements-part2 :)
Otros consejos
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 });
}
}