I am try to implements datatables filter inside polymer from this link https://jsfiddle.net/bindrid/2bkbx2y3/6/
But when I apply into polymer I found some issue when push to datatables a plugin method. in polymer I use vaadin-date-picker as datepicker, and here's my code :
HTML
<template> <form class="form-inline m-b"> <div class="form-group form-group-sm"> <vaadin-date-picker id="min" placeholder="Start"></vaadin-date-picker> <vaadin-date-picker id="max" placeholder="End"></vaadin-date-picker> </div> </form> <table id="mainTable" class="table table-condensed table-striped table-bordered" style="width: 100%"> <thead> <tr> <th>STAD</th> </tr> </thead> </table>
Script :
class DataTableD extends Polymer.Element { static get is() { return 'data-table-d'; } ready() { super.ready(); var min = this.$.min; var max = this.$.max; //push method into search $.fn.dataTable.ext.search.push(function (settings, data, dataIndex) { alert("min . ." + min) //min . .[object HTMLElement] var startDate = new Date(data[0].replace( /(\d{2})-(\d{2})-(\d{4})/, "$2/$1/$3")); if (min == null && max == null) {alert("startDate . ." + startDate);} if (min == null && startDate <= max) {alert("startDate . ." + startDate);} if (max == null && startDate >= min) {alert("startDate . ." + startDate);} if (startDate <= max && startDate >= min) {alert("startDate . ." + startDate);} return false; }); // Event listener to the two range filtering inputs to redraw on min.addEventListener('value-changed', function() { window.setTimeout(function() { max.value = min.value; max.open(); }, 500); this.$.mainTable.draw(); }); } _initializeDatatable() { if ( ! this.$mainTable) { // Make the jQuery object of the mainForm and arrivalTable. this.$mainTable = $(this.$.mainTable); } this._dataTable = this.$mainTable.DataTable({ }); } } window.customElements.define(DataTableD.is, DataTableD);
hope someone can share the idea to make it works, thx
===========================
Here below I tried to illustrate another way to filter :
DEMO
EDIT
How to pass data outside Polymer
outside of the Polymer: