Jump to content

Solution To Data Export Of Player Stats For Bryan


2 replies to this topic

#1 Belorion

    Member

  • PipPipPipPipPipPipPipPipPipPip
  • Legendary Founder
  • Legendary Founder
  • 5,469 posts
  • LocationEast Coast

Posted 06 June 2013 - 05:33 AM

In the last ask the devs Bryan stated that they would like to make available the export of player data from the web site eventually. I am assuming due to time constraints for developers. I see that you are already using jQuery on your web pages, and there exists a jQuery plug in which does all the work for you. All that would have to be done is downloading the dataTable plugin (this is used by the Master Unit List among a growing number of websites) from here: http://datatables.net/download/ and include something along the lines of the following in the web page (changing the filepaths of course to match where you host the dataTable libraries.) :

<script src = "http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>
<script src = "DataTables-1.9.4/extras/TableTools/media/js/ZeroClipboard.js"></script>
<script src = "DataTables-1.9.4/extras/TableTools/media/js/TableTools.min.js"></script>
<script>
$.extend( true, $.fn.DataTable.TableTools.classes, {
"container": "btn-group",
"buttons": {
  "normal": "btn",
  "disabled": "btn disabled"
}
} );
 
var oTable = $('table').dataTable({
"iDisplayLength": 100,
"sDom": 'lrtT',
"oTableTools": {
  "aButtons": [ "copy", "csv" ],
  "sSwfPath": "http://localhost/slim/slim-web/src/main/webapp/app/lib/DataTables-1.9.4/extras/TableTools/media/swf/copy_csv_xls_pdf.swf"
}
});
</script>


The result is a fully sortable, client side dynamic table that can be exported or copied to the clip board. Filtering can be added as well, but I left that bit out for aesthetic reasons.

Edited by Belorion, 06 June 2013 - 05:50 AM.


#2 Belorion

    Member

  • PipPipPipPipPipPipPipPipPipPip
  • Legendary Founder
  • Legendary Founder
  • 5,469 posts
  • LocationEast Coast

Posted 06 June 2013 - 06:57 AM

I should add, that since the MWOMerc pages are rendered in HTML5 if you highlight a table (any table) and drag it to a spreadsheet or word document then the data will be imported into the open document.

So to some level an explicit export is unneeded.

#3 Belorion

    Member

  • PipPipPipPipPipPipPipPipPipPip
  • Legendary Founder
  • Legendary Founder
  • 5,469 posts
  • LocationEast Coast

Posted 07 June 2013 - 08:56 PM

People can idividually add support for dataTables on the fly if they have Firebug installed. It isn't possible to do this with TableTools as there are cross server security constraints that keep it from working, but here is how you add support for just sorting/filtering.

Open up firebug (or the Javascript console of which ever browser you prefer.) and run the following commands.

var script = document.createElement("script"); script.src = "http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"; document.body.appendChild(script);
$('table').dataTable();

Edited by Belorion, 07 June 2013 - 08:56 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users