Regarding row_details example.
Regarding row_details example.
jQuery_user
Posts: 27Questions: 0Answers: 0
Hello,
I am using the row_details example in my project.
http://datatables.net/examples/api/row_details.html
In my case, I have to show filtered rows from an array (stored in the session) in the row details.
This array consists of objects (of class X)
So far, I can alert and get the size of the array in the function fnFormatDetails ( oTable, nTr )
But when I print the array, I get nulls.
Is this possible?
I am using the row_details example in my project.
http://datatables.net/examples/api/row_details.html
In my case, I have to show filtered rows from an array (stored in the session) in the row details.
This array consists of objects (of class X)
So far, I can alert and get the size of the array in the function fnFormatDetails ( oTable, nTr )
But when I print the array, I get nulls.
Is this possible?
This discussion has been closed.
Replies
Allan
The servlet stores the array in the session.
The JSP has access to this array.
Here is my code:
[code]
function fnFormatDetails ( oTable, nTr )
{
var aData = oTable.fnGetData( nTr );
var sOut = '';
<%
ArrayList lines = (ArrayList) getSession().getValue("resultLines");
LineItem[] lineArray = new LineItem[lines.size()];
int lineSize = lineArray.length;
%>
alert("Array: "+<%=lineArray%>);
//sOut += 'Rendering engine:'+aData[1]+' '+aData[4]+'';
//sOut += 'Link to source:Could provide a link here';
//sOut += 'Extra info:And any further details here (images etc)';
sOut += '';
return sOut;
}
[/code]
When I click on the row details, I see the array with all nulls.
This array is a custom object with around 10 attributes (along with getters/setters).
How can I realize this array on the client side using javascript, so I can print this array as a table.
Perhaps what is needed, is the information in your array is put into the html table with hidden columns - much like I've done with my example. Another option is that you could create a static Javascript array of information and look that up for each row in the table.
Allan
[code]
<%
ArrayList lines = (ArrayList)getSession().getValue("resultLines");
LineItem[] lineItems = (LineItem[]) lines.toArray(new LineItem[lines.size()]);
if(lineItems != null) { %>
var linesJS = new Array(<%
for(int i = 0; i < lineItems.length; i++) {
out.print("\""+lineItems[i]+"\"");
if(i+1 < lineItems.length) {
out.print(",");
}
}
%>);
<% } %>
alert("array: "+ linesJS);
[/code]
when I view source, it has random garbled values in the "linesJS" array, as I am copying an Object Array into var Array.
Is it possible to create an array of corresponding javascript objects?
Allan
I haven't worked much with javascript objects. This all boils down to declaring an array of custom objects, similar to this:
[code]var myCars=new Array("Saab","Volvo","BMW");[/code]
Can you provide syntax, or a simple example array with say 2 objects (properties: x, y)
Thanks