jQWidgets Forums

jQuery UI Widgets Forums Grid How to Fill the grid with dynamic data from java's arraylist with ajax call Reply To: How to Fill the grid with dynamic data from java's arraylist with ajax call


Ranchs
Member

Hi Peter,

Thanks very much for the suggestion.

Now that i have been successful in converting the ArrayList of java which is indeed an collection of ArrayList holding the rows of data to be populated to the grid as json object (through Gson) using the below code as :

With in the Servlet :

// ArrayList of ArrayList containing row data
ArrayList <ArrayList > alSearchData = new ArrayList <ArrayList > ();

// ArrayList containing individual row data as Strings
ArrayList alRowData = new ArrayList ();

// I have put the data such a way into the arraylist to be easily retrieved to javascript array as below:

1st row
alRowData.(“Name:”+”Ranchs”);
alRowData.(“Type:”+”Search”);
alRowData.(“Dept:”+”Support”);
alRowData.(“ID:”+”0WRT12”);

alSearchData .add(alRowData);

2nd row
alRowData.(“Name:”+”Klips”);
alRowData.(“Type:”+”Search”);
alRowData.(“Dept:”+”Support”);
alRowData.(“ID:”+”0WRT456”);

alSearchData .add(alRowData);

After which i have done the below code to convert to json:

response.setContentType(“application/json”);
response.setCharacterEncoding(“UTF-8″);
response.getWriter().write(new Gson().toJson(alSearchData));

I have problem in retreiving the data with in the below jquery code:

$(‘#tab1′).bind(‘selected’, function (event) {
var tabSelected = $(‘#tab1′).jqxTabs(‘getTitleAt’, event.args.item);

if(tabSelected == ‘Ranchs’){
$.ajax({
type: “GET”,
url: “/ePax/servlet/Controller?handler=10&obid= ” + param1,
data: “param2=true&nameddata=reports&queryParam=” + param1,
datatype:”json”,
success: function(data){
// Kindly help me out in retrieving the data from the json object here.
}
});
}

});

Kindly help me out in retreiving the data inside the ajax success call back method.