Fill table instead of filtering

Fill table instead of filtering

esbenboyeesbenboye Posts: 5Questions: 1Answers: 0
edited March 2014 in General
I was wondering if it was possible to fill in the data to the datatable instead of filtering it?

I have a table with some rows in it, and I would like to have an empty table to begin with and the table also being empty if there's no search (all search fields are blank).

I've tried to use the $("...").bind("filter", ...) and test if the visible rows equals the total number of rows, and make a filter, that would hide all rows, but that gave me a inifinite loop.
I've also considered using the serverside/ajax based datasource, but would rather not, since it will require a fairly large rewrite of code.

Any suggestions?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I guess what you could do is to use a custom filter ( http://datatables.net/development/filtering - "Custom row filters") and display reject all rows if the search input is empty. Then the default filtering could be used if it is not. Haven't tried it, but that would be one option.

    Allan
  • esbenboyeesbenboye Posts: 5Questions: 1Answers: 0
    Cool - That works like a charm! I don't think I would've thought of that :)
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Good to hear that works. Using DataTables as a search comes up now and then, so good to know I can point folks here now :-)

    Allan
This discussion has been closed.