Sha256: 1eba79e986d76d034f2d81b1695d0d3c39023b8cb95a31abb1944564ae5fc841

Contents?: true

Size: 1.71 KB

Versions: 23

Compression:

Stored size: 1.71 KB

Contents

jQuery.fn.addDataTable = function(dataTableOptions) {

  var defaultDataTableOptions = {
    "bJQueryUI": true,
    "bProcessing": true,
    "bServerSide": true,
    "bFilter": false,
    "bSort": false,
    "asStripClasses": [ '','tablerow-bg-shade' ],
    "bPaginate": true,
    "bLengthChange": false,
    "sPaginationType": "full_numbers",
    "iDisplayLength": eval("if(typeof getDisplayLength == 'function') { getDisplayLength() }"),
    "sDom": 'rpitip',
    "bInfo": true,
    "isPaginate": true,
    "fnInitComplete" : function() {
      addTitles();
    },
    "fnServerData": function ( sSource, aoData, fnCallback ) {
      jQuery.getJSON( sSource, aoData, function (json) {
        fnCallback(json);
        initPaging();
        addTitles();
      });
    }
  };

  if(!dataTableOptions.sAjaxSource) {
    defaultDataTableOptions.bProcessing = false;
    defaultDataTableOptions.bServerSide = false;
    defaultDataTableOptions.bInfo = false;
    defaultDataTableOptions.bPaginate = false;
  }

  var settings = jQuery.extend(defaultDataTableOptions, dataTableOptions);

  // Setup the datatable.
  jQuery(this).dataTable(settings);
};

function initPaging() {
  jQuery('#datatable_wrapper > div.dataTables_paginate > span.fg-button').click(function(){
    return false;
  });

  jQuery('#datatable_wrapper > div.dataTables_paginate > span > span.fg-button').click(function(){
    jQuery('#datatable').dataTable().fnDraw();
    return false;
  });
}

function addTitles() {
  jQuery('#datatable tbody tr td').each( function() {
    this.setAttribute( 'title', jQuery(this).text().trim());
  });
}

function SetFirstPage() {
  jQuery('#datatable').dataTableSettings[0]._iDisplayStart = 0;
  jQuery('#datatable').dataTable().fnDraw();
}

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
naf-1.1.2 app/assets/javascripts/jquery.dataTables.custom.js
naf-1.1.1 app/assets/javascripts/jquery.dataTables.custom.js
naf-1.1.0 app/assets/javascripts/jquery.dataTables.custom.js