Displaying hidden field content working inconsistently
Displaying hidden field content working inconsistently
vikinggoat
Posts: 26Questions: 0Answers: 0
I'm using fnGetPosition, and fnGetData to display the contents of a hidden cell in the area created when I use fnOpen.
(Also using TableTools by the way).
But for some reason this only seems to work intermittently.
It will run fnOpen just fine for the first set of info given, but when I change the sort in anyway it goes intermittent, maybe the first few if any will run fnOpen and populate.
Has anyone come across this before?
(Also using TableTools by the way).
But for some reason this only seems to work intermittently.
It will run fnOpen just fine for the first set of info given, but when I change the sort in anyway it goes intermittent, maybe the first few if any will run fnOpen and populate.
Has anyone come across this before?
This discussion has been closed.
Replies
If I wanted to arrange some support time, aside from going through the Support page, what might I need to do?
Thanks very much for picking up DataTables support! That's all you need to do to get priority support :-).
Having said that, are you able to give me a link to your page so I can see what is happening first hand?
Am I right in saying that the problem you are facing is that the click to call fnOpen sometimes works and sometimes doesn't? If so, how are you attaching your click event listener?
Thanks,
Allan
Here is the link, http://mobilitylab.org/bikearlington/cabistations-dev/rollUpReport5.php
The first being the intermittent On click event, which currently working on the first grouping of rows and a handful of others.
And also:
Allowing multiple "sMod" usages. (Using TableTools,ColumnFilterWidgets, and ColReorder together).
Sorting by invisble rows when clicking on column header instead of that columns information.
Expanding/collapsing all sub-table entries for viewing.
Expanding all sub-table entries for non-filtered parent rows when "printing".
If using AJAX for server side sub-table info acquisition:
Expanding/collapsing all sub-table entries.
Expanding all sub-table entries for non-filtered parent rows when "printing".
The problem here is that you are using static events:
[code]
$("#parentTable tbody tr").click( function (){
[/code]
after the table has been initialised. This means that only the 10 rows sown on first draw will receive the event handler - hence why you appear to sometimes get rows which have the event handler, and sometimes not. Those that do were not he front page on the first draw.
To address this use delegate events:
[code]
$("#parentTable tbody").on( 'click', 'tr', function (){
[/code]
that will always work. See also: http://datatables.net/faqs#events . Also, Visual Event is quite useful for seeing what is going on with events and which DOM elements have what events attached: http://www.sprymedia.co.uk/article/Visual+Event+2 .
> 2. Allowing multiple "sMod" usages. (Using TableTools,ColumnFilterWidgets, and ColReorder together).
Do you mean sDom ? Each "feature" has its own letter, so to get the feature, just add it to the string. For example you might have
[code]
"sDom": 'RC<"clear">lfrtip',
[/code]
To have ColRender and ColVis together. Add 'T' in to get TableTools - etc. See this example: http://datatables.net/release-datatables/extras/ColReorder/colvis.html .
> 3. Sorting by invisble rows when clicking on column header instead of that columns information.
Absolutely - to do that use the aDataSort parameter: http://datatables.net/ref#aDataSort . That will let you tell DataTables to sort one column by the data form another. You might also be interesting in this blog which shows how you can use different data for sorting, filtering, display etc: http://datatables.net/blog/Orthogonal_data .
> 4. Expanding all sub-table entries for non-filtered parent rows when "printing".
This one is a bit more difficult as TableTools doesn't currently provide an event to indicate that it is switching into print view. What would need to happen is that TableTools would give you that event, which you have listened for, and then you would show all the inner tables that are included in the filter. You would also need to keep track of which rows you opened of rate print view so you could then close them when TableTools says that it is finished with the print view. Does this sound okay?
[quote]
5. If using AJAX for server side sub-table info acquisition:
Expanding/collapsing all sub-table entries.
[/quote]
The 'live' event I mentioned in 1 above will cope with that no problem. You just need to make sure that the information is available in the table. This example shows how show/hide can be done with server-side processing: http://datatables.net/release-datatables/examples/server_side/row_details.html
Regards,
Allan
The solution for Issue 1 doesn't seem to be effective, nothing occurs on click.
Do you see anything on the Firebug / Inspector javascript console? Perhaps a script error that would indicate what is wrong.
Regards,
Allan
Are there plans to provide TableTools with a 'switch to print view' functionality?
You mean an API call that will activate the TableTools print view? Yes :-). I've working on an upgrade to TableTools at the moment and that is something that I can include.
Regards,
Allan
Regards,
Allan
Link: http://mobilitylab.org/bikearlington/cabistations-dev/rollUpReport5.php
Code:
[code]
$("#parentTable tbody tr").on( "click", "td.detailSwitch", function (){
var nTr = $(this).parent();
if (oTable.fnIsOpen(nTr)){
oTable.fnClose(nTr);
}else{
var locNum = $(nTr).attr("id");
getRollUpComments(locNum, nTr);
}
});
function getRollUpComments(locNum,nTr){ //Load the map data
$.ajax({
type: "POST",
url: "getRollUpComments.php",
cache: false,
data:{locNum:locNum},
dataType: "html",
success: function(data) {
oTable.fnOpen(nTr, data, "info_row" );
}, //end success
error:function (xhr, ajaxOptions, thrownError){
alert("Please try again.");
}
});
}
[/code]
Do you mean that it "isn't taking place". Certainly I see that Ajax request on the page, but the row doesn't "open".
> var nTr = $(this).parent();
I suspect you might need to add [0] after "parent()" on that line. The DataTables API methods expect nodes, not jQuery objects.
> Also, how do you not allow the head and foot cells for a column to be effect as mine are, they don't need sorting or filtering.
To disable sorting us bSort : false, while to disable filtering, remove either the "columnFilter" plug-in.
Regards,
Allan
Any reason why all but the Print button might be not functioning?
Below is the code for the TableTools initialisation.
[code]
oTable = $("#parentTable").dataTable({
"aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
"aoColumnDefs": [
{ "aDataSort": [ 7, 6, 8, 9, 10 ], "aTargets": [ 0 ] },
{ "bVisible": false, "aTargets": [ 6 ] }, //zip
{ "bVisible": false, "aTargets": [ 7 ] }, //state
{ "bVisible": false, "aTargets": [ 8 ] }, //city
{ "bVisible": false, "aTargets": [ 9 ] }, //street
{ "bVisible": false, "aTargets": [ 10 ] } //street number
],
"sDom": \'TR<"clear">lfrtip\'
}).columnFilter();
[/code]
If you'll go to this URL (http://mobilitylab.org/bikearlington/cabistations-dev/rollUpReport5.php), you will see that the "MAP" and drilldown functions will only work for the first set of rows shown and will now work for any rows seen as a result of a sort change, advancing to the next set of results, or changing the number of entries shown.
Also, of the "export" buttons, only the Print button seems to be currently working.
Did you resolve that issue? It appears to be working no problem now.
> Also, of the "export" buttons, only the Print button seems to be currently working.
TableTools is trying to load the file http://mobilitylab.org/bikearlington/cabistations-dev/media/swf/copy_csv_xls_pdf.swf - but that is a 404 error. You need to either put the SWF file there, or set the SWF path ( http://datatables.net/release-datatables/extras/TableTools/swf_path.html ) explicitly to where the file is. That file allows TableTools to do local file exporting and clipboard access.
> you will see that the "MAP" and drilldown functions will only work for the first set of rows shown
Your selector for the event:
[code]
$("#parentTable tbody tr td").on( "click", "div.detailSwitch", function (){
[/code]
is over keen! At the moment it is putting a delegated event handler on the TD cells that it finds in the table when that code runs. But when you change page, those elements aren't there any more. If you just change it to:
[code]
$("#parentTable tbody").on( "click", "div.detailSwitch", function (){
[/code]
so the delegated event handler is on the TBODY element, which is always there, this will work nicely.
Regards,
Allan
Regards,
Allan
Also, when using the Print function (which I haven't done yet since I lack a printer) do the headers repeat on the tops and bottoms of each printed page?
Depending on your browser - yes. I think all browsers do that now - based on the THEAD / TBODY, but that comes down to how the browser renders the print view for the print driver.
Allan
I'm putting in the drilldown; separately, so that that none of the Extras transfers over?
Allan
That is correct - the exported files are basically CSV text files, and thus can contain no formatting. Even the "Excel" file is really just a CSV UTF-16LE file. It is possible to create a true Excel file, but it is rather complex, and not something that TableTools is yet capable of doing. It is on the roadmap though.
> one of the populated drill downs are appearing
The exported data is entirely cell based - it currently doesn't show the data from any "details" rows I'm afraid (apart from anything else, that would break the CSV column count).
> also in some of the export modes the hidden columns are appearing, which shouldn't happen.
Have you specified mColumns at all ( http://datatables.net/extras/tabletools/button_options#mColumns )? By default all columns are exported, but you can set mColumns to "visible" to export only visible columns.
Allan
Wouldn't it simply be possible to do something like this for the CSV files?
Where A2 and A4 are drilldown areas.
"A1","B1","C1"
"A2 ",,
"A3","B3","C3"
"A4",,
"A5","B5","C5"
"A6","B6","C6"
"A7","B7","C7"
Allan