Sha256: 515fb2889880c85acbd2b53586857aa8aa884ad5fcedc0f5b27a1db41bf29665

Contents?: true

Size: 1.89 KB

Versions: 25

Compression:

Stored size: 1.89 KB

Contents

function datatable_list(table, ordered_columns, sorting, filter){
  if (sorting == undefined){
    var sorting = 0
  }
  if (filter == undefined){
    var filter = true
  }
  if (length == undefined){
    var length = 50
  }
  var asInitVals = new Array();
  var remote = false

  if ($(table).data('source') != null)
    remote = true;

  var search = false

  if ($(table).data('search') != null)
    search = true;

  var notSortableColumns = []
  var columnIndex = 0;
  $(table).find("th").each(function(index, item){
    if(!$(item).data("sortable"))
      notSortableColumns.push(index);
  });

  var oTable = $(table).dataTable({
   "aoColumnDefs": [
        {
         bSortable: false,
         aTargets: notSortableColumns
        }
      ] ,
    "bFilter": filter,
    "bProcessing": remote,
    "bServerSide": remote,
    'sAjaxSource': generateDataSource(table),
    "sPaginationType": "full_numbers",
    "iDisplayLength": length,
    "bRetrieve": true,
    "fnServerParams": function(){
      $(".dataTables_processing").width($(".dataTable").width());
      $(".dataTables_processing").height($(".dataTable").height() + 40);
      $(".dataTables_processing").html("<div class='datatables-loading'>Processando</div>")
    },
    'oLanguage': dataTablesTranslation
  });

  if(!search)
    $(".dataTables_filter").hide();
}

function generateDataSource(table){
  var url = $(table).data('source');
  url = addUrlParam(url, "scope", table);
  url = addUrlParam(url, "special_scope", table);
  url = addUrlParam(url, "from", table);
  url = addUrlParam(url, "to", table);
  url = addUrlParam(url, "advancedquery", table);
  return url;
}

function addUrlParam(url, param, table){
  if($(table).data(param) != undefined && $(table).data(param) != ""){
    if(url.indexOf("?") > 0)
      url = url + "&";
    else
      url = url + "?";
    return url + param + "=" + encodeURI($(table).data(param));
  }
  else
    return url;
}

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
carnival-0.0.55 app/assets/javascripts/carnival/data_tables_functions.js
carnival-0.0.54 app/assets/javascripts/carnival/data_tables_functions.js
carnival-0.0.53 app/assets/javascripts/carnival/data_tables_functions.js
carnival-0.0.52 app/assets/javascripts/carnival/data_tables_functions.js
carnival-0.0.51 app/assets/javascripts/carnival/data_tables_functions.js
carnival-0.0.50 app/assets/javascripts/carnival/data_tables_functions.js
carnival-0.0.49 app/assets/javascripts/carnival/data_tables_functions.js
carnival-0.0.48 app/assets/javascripts/carnival/data_tables_functions.js
carnival-0.0.47 app/assets/javascripts/carnival/data_tables_functions.js
carnival-0.0.45 app/assets/javascripts/carnival/data_tables_functions.js
carnival-0.0.44 app/assets/javascripts/carnival/data_tables_functions.js
carnival-0.0.43 app/assets/javascripts/carnival/data_tables_functions.js
carnival-0.0.42 app/assets/javascripts/carnival/data_tables_functions.js
carnival-0.0.41 app/assets/javascripts/carnival/data_tables_functions.js
carnival-0.0.40 app/assets/javascripts/carnival/data_tables_functions.js
carnival-0.0.39 app/assets/javascripts/carnival/data_tables_functions.js
carnival-0.0.38 app/assets/javascripts/carnival/data_tables_functions.js
carnival-0.0.37 app/assets/javascripts/carnival/data_tables_functions.js
carnival-0.0.36 app/assets/javascripts/carnival/data_tables_functions.js
carnival-0.0.35 app/assets/javascripts/carnival/data_tables_functions.js