Displaying hidden field content working inconsistently

Displaying hidden field content working inconsistently

vikinggoatvikinggoat Posts: 26Questions: 0Answers: 0
edited May 2012 in General
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?
«1

Replies

  • vikinggoatvikinggoat Posts: 26Questions: 0Answers: 0
    edited May 2012
    Allan,
    If I wanted to arrange some support time, aside from going through the Support page, what might I need to do?
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Hi,

    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
  • vikinggoatvikinggoat Posts: 26Questions: 0Answers: 0
    Correct, I tossed some alerts in to show breaking points.
    Here is the link, http://mobilitylab.org/bikearlington/cabistations-dev/rollUpReport5.php
  • vikinggoatvikinggoat Posts: 26Questions: 0Answers: 0
    There are also a few other things I wanted to run by you as well, could you let me know if you think I would need to get more time, and if so how much.

    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".
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    > 1. Intermittent clicks:

    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
  • vikinggoatvikinggoat Posts: 26Questions: 0Answers: 0
    For 2; yes, sorry sDom.
    The solution for Issue 1 doesn't seem to be effective, nothing occurs on click.
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Which version of jQuery are you using? The 'on' API method needs 1.7+. Prior to 1.7 you can use 'live' like in the FAQ.

    Do you see anything on the Firebug / Inspector javascript console? Perhaps a script error that would indicate what is wrong.

    Regards,
    Allan
  • vikinggoatvikinggoat Posts: 26Questions: 0Answers: 0
    That seems to have been the issue there, I was using 1.6+

    Are there plans to provide TableTools with a 'switch to print view' functionality?
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    > 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
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    I've just added this ability to TableTools and it will be included in 2.1. You can get the current code directly from GitHub: https://github.com/DataTables/TableTools/commit/23d4764d26674ab71fb1b34124a61b51a423a492

    Regards,
    Allan
  • vikinggoatvikinggoat Posts: 26Questions: 0Answers: 0
    Since I till have some time left, I wanted to pass this bit of code by you, I've modified the code so a particular cell would have to be clicked, all but the fnOpen is taking place, and I can't for the life of find why. Any assistance would be appreciated.
    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]
  • vikinggoatvikinggoat Posts: 26Questions: 0Answers: 0
    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.
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    > but the fnOpen is taking place

    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
  • vikinggoatvikinggoat Posts: 26Questions: 0Answers: 0
    One last question for the same URL (http://mobilitylab.org/bikearlington/cabistations-dev/rollUpReport5.php)
    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]
  • vikinggoatvikinggoat Posts: 26Questions: 0Answers: 0
    According to the Visual Event Bookmarklet, none of other buttons have events associated with them, but I'm certain they worked previously.
  • vikinggoatvikinggoat Posts: 26Questions: 0Answers: 0
    Seems I'm going to need your help a bit more.
    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.
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    > Any reason why all but the Print button might be not functioning?

    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
  • vikinggoatvikinggoat Posts: 26Questions: 0Answers: 0
    Isn't the following path automatically generated? http://mobilitylab.org/bikearlington/cabistations-dev/media/swf/copy_csv_xls_pdf.swf
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    No - its an SWF file that comes with TableTools ( https://github.com/DataTables/TableTools/tree/master/media/swf ). The URL that TableTools uses by default is relative ( "media/swf/copy_csv_xls_pdf.swf" ). You need to either tell TableTools another path where it can find the swf file, or put the file in that location.

    Regards,
    Allan
  • vikinggoatvikinggoat Posts: 26Questions: 0Answers: 0
    I've put the file in that location, but it doesn't seem to be having any effect.
    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?
  • vikinggoatvikinggoat Posts: 26Questions: 0Answers: 0
    Sorry Allan, I take that back, they are working now, just slowly on my rickety old PC.
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    > 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
  • vikinggoatvikinggoat Posts: 26Questions: 0Answers: 0
    Another question, is there anyway for me to apply Datatables (without tabletools) to the tables
    I'm putting in the drilldown; separately, so that that none of the Extras transfers over?
  • vikinggoatvikinggoat Posts: 26Questions: 0Answers: 0
    Followed by yet another, all formatting is lost in anything but Print mode, and none of the populated drill downs are appearing; also in some of the export modes the hidden columns are appearing, which shouldn't happen.
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Sure - just call $(...).dataTable({...}); without specifying the 'T' option in sDom. It is the 'T' that activates TableTools.

    Allan
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    > Followed by yet another, all formatting is lost in anything but Print mode

    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
  • vikinggoatvikinggoat Posts: 26Questions: 0Answers: 0
    Actually, Print is showing the Filter inputs at the bottom.
  • vikinggoatvikinggoat Posts: 26Questions: 0Answers: 0
    No, I only used bVisible.
  • vikinggoatvikinggoat Posts: 26Questions: 0Answers: 0
    When I meant formatting I was less meaning graphically and more mColumns and drilldown related.

    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"
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Yes it would be possible to do what you suggest with the details rows, but it is not something that is yet implemented. I'll look at including this in v2.1.1, which will be available shortly (should be later today).

    Allan
This discussion has been closed.