Giter Club home page Giter Club logo

Comments (7)

hydrocat avatar hydrocat commented on July 3, 2024

Hey @Sysix
So, you have an interesting point. I believe that filtering by callback sounds like someone would expect from a filter.

With this in mind, I am thinking about a few points:

  1. A filter is a Boolean function
  2. The filter is hooked to column ( just like it is now )
  3. The argument for the filter is the value in a cell.
    In the example, it would be either 'Assistant' or 'Manager'
  4. The new set of rows is given by applying the filter to all the original initial rows, keeping those which the filter returns true.

And I have some remarks on that:

  • Point 1 is the whole idea of function filters but I wonder how that would apply for the simple case, that is, how would the old example be implemented.

    Currently, once the row with a filter is clicked, we select only the rows whose cell value is the same as the filtered term. On the second click, we use the next term and finally, show all rows.

    In the example, it goes like this:

    All rows whose Job is AssistantAll rows whose Job is Manager → all_items → Assitant ...

    My question is, How do we handle functions as filters ? I have a few Ideas

    • Apply it on click, reset on next click.
    • Have a list of functions to be applied, similar to what we have now.
    • Apply it every time the user clicks the row
      On a side-note, This one seems to be the most straight-forward way but I feel that it puts more strain on the person that is using this library so that the provided function is able to change it's behaviour on every call and also be able to 'reset' and show all values again.
  • Point 3 might be more useful if the callback had access to the entire row. This would enable us to write more interesting filters, for example, Administrator with .org emails.

Also, I see that on your example, you refer to the functions's arguments as colValue and colElement. What is the latter meant to represent ?

Hmm.. Looks like I wrote quite a bit.
I like the idea and I'd like your feed back on this feature.

from simple-datatables.

Sysix avatar Sysix commented on July 3, 2024

Thanks for your Feedback.

I agree to all points with you.

Also, I see that on your example, you refer to the functions's arguments as colValue and colElement. What is the latter meant to represent ?

colValue should be the innerText from the td-HtmlElement. The colElement should be the
td-HtmlElement itself.

To your question how we should handle the filters:

I would let the developer use it how he likes it. The filters and the config are filters which are applied at the start and can be removed via the method.
we should discuss how we get the filterId, maybe easy about a filterList property

The filters should be stackable. The developer need remove active filters manuelly.

Maybe as a Plugin we can create a Layout-Extension with predefined Buttons

from simple-datatables.

hydrocat avatar hydrocat commented on July 3, 2024

In the core,
When a user clicks in a header, first time, we apply the predicate.
On the second click, do we remove the predicate or apply the predicate again ?

from simple-datatables.

Sysix avatar Sysix commented on July 3, 2024

In the basic version no events should be set for the header or columns. Let the developer choice how he want to implement it

from simple-datatables.

hydrocat avatar hydrocat commented on July 3, 2024

For the events, you may hook something into https://github.com/fiduswriter/Simple-DataTables/wiki/Events#datatablesort
By default, this event is fired whenever you click the column.

from simple-datatables.

hydrocat avatar hydrocat commented on July 3, 2024

@johanneswilm Maybe you could close this ?

from simple-datatables.

johanneswilm avatar johanneswilm commented on July 3, 2024

ok

from simple-datatables.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.