Hi guys, Pablo was asking about Datatables which is a JS plugin, not databases :) Pablo, In Smalltalk hub there are a couple of DataTables projects. It would be interesting to know which one is the "official". Second, please ask in Seaside mailing list. For my client, I forked the original DatatablesFileLibrary because I needed extra plugins. And then, I simple used JS. So the steps are simply add the file library into the libs of your app. Then render some html table. Finally, invoke some JS. Either from jQuery or from normal JS. Note that I can imagine that some of the Datatables found in Smalltalkhub should have examples. Check them out. Something like this (it's full of domain stuff and probably I am copy pasting with errors but will help you to get the idea): 1) Register lib to app: app addLibrary: DataTablesFileLibrary (or whatever class name is it) 2) Then render table and container (whatever you want, however you want...you simple need a container and a table). containerDiv := html div. containerDivId := containerDiv ensureId. containerDiv class: 'reportContainer'; with: [ html table id: self tableId; with: [ self renderTableOn: html. ]. html script: (FaDataTablesHelper datatablesScriptFor: tableID tableHeightString: '"scrollY": (0.80 * $(window).height()),' containerDivId: containerDivId). The magic here is that to the generated table you pass via #script: the Datatables JS. 3) Generate datatables JS: FaDataTablesHelper class >> datatablesScriptFor: tableID tableHeightString: aTableHeightString containerDivId: aContainerDivId ^ ' $(document).ready(function() { var getCellText = function (elem) { //get only the element text return elem.contents().filter(function() { return this.nodeValue; }).text(); }; // this is so that the table does not use all the height space and hence the horizontal scroll looks outside the empty space. // By default, we make the table a max height of a % of the windows. var oTable = $(''#', tableID asString ,''').DataTable( { ', aTableHeightString, ' "scrollX": "100%", "scrollCollapse": true, "paginate": false, "stateSave": false, "stateDuration": -1, "destroy": true, "filter": false, "ordering": false, "searching": false, "sort": false, "orderClasses": false, "autoWidth": false, "jQueryUI": false, // J: ColResize. // I: ColPin. It needs ColReorder. // R: ColReorder // "dom": ''C<"clear">Rt'', "dom": ''t'', // colVis: { // label: function (index, title, th) { // return $(''a[href]'', th).text() || getCellText($(th)); // } // }, // this is in case I want to use the paginate for the Scroller "iDisplayLength": -1 } ); // oTable.colResize.init({fixedLayout: true, dblClick: ''matchContent''}); // Previosuly it was the below line, but this is bad...because if the widths of the columns keep fixed // all along the session, we may wast a lot of space because columns were kepts with its original width... // and when filtering, sorting, etc..the width of the column changes to better adjust its width needs..." // Check if body width is higher than window width :) if ( $(''#', tableID asString ,''').width() > $("#', aContainerDivId,'").width() ) { // Add default fixedColumns // oTable.colPin.init({ // fixedColumns: { // leftColumns: 1, // rightColumns: 1, // heightMatch: ''auto'' // } // }); new $.fn.dataTable.FixedColumns( oTable, { leftColumns: 1, rightColumns: 1 } ); }; //table is bigger than container }); // document on load '. This point 3) depends completely on how you want to use Datatables. Read it's documentation in order to know what you need/want. Also..use the Developer Tools of the browser (console) since you may have missing plugins, or wrong JS code etc. That console will be your friend until you make it work. Cheers, On Sat, Dec 5, 2015 at 11:25 AM, [hidden email] <[hidden email]> wrote:
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Free forum by Nabble | Edit this page |