RobertoPrevato / jQuery-KingTable

A jQuery plugin for administrative tables that are able to build themselves, on the basis of the input data.
MIT License
117 stars 33 forks source link

In filters date input format does not trigger #7

Closed sir21 closed 7 years ago

sir21 commented 7 years ago

I tried to use date to filter data in the table, input type 'text' is trigger the function in filter. However date input type does not trigger the filter.

Here part of my code

index.txt

RobertoPrevato commented 7 years ago

Hi @sir21 , Thanks for opening this issue, and sorry for not answering yesterday: I didn't manage to write. It was indeed a bug: I wasn't binding an event handler to input type date, email, time, week, datetime, etc. I modified the piece of code that is responsible of DOM manipulation in the current implementation ("jquery.kingtable-lodash.js"), to support these kinds of controls out of the box, inside custom views.

I successfully tested using an input type="date", and did a push, including several other improvements. Please let me know if it resolves the problem.

By the way, if you desire to customize the events that are bound by the table, you have these options:

  1. To change the events globally (all instances of KingTable):

    // Note: the events object is using the same format of Backbone library, eg: "change .my-input": "functionName"
    $.KingTable.prototype.defaults.events = {
      "eventname selector": "functionName"
    };
    
    $.KingTable.prototype.functionName = function yourHandler(e) {
     // this function is called in the context of the KingTable instance
    };
    
    // or (equivalent):
    $.KingTable.prototype.defaults.events = {
      "eventname selector": function yourHandler(e) {
         // this function is called in the context of the KingTable instance
      }
    };
  2. To define event handlers for a specific instance of KingTable, use the events option
    var table = new $.KingTable({
    events: {
       "click #special-button": function (e) {
          // Nota bene: if you need to get the clicked element, use $(e.target) or $(e.currentTarget)
          // this function is called in the context of the table
          console.log("[*] Hello There!");
       }
    }
    })
sir21 commented 7 years ago

Thanks for fixing the issue. I was able to do that using events. Now date filter event is trigger as normal in text. Thanks again for fixing it.