• Resolved tiagomagnuss

    (@tiagomagnuss)


    Hey Tobias, I’d like to thank your answer on my previous topic, I’ve got myself to learn some jQuery too!

    But now I have some questions:

    I got to click a button and add a specific textbox’s text to the “#tablepress-1_filter input”, it works, but the function that is called when the User types ain’t triggered. Can you help me to find the function’s name/the input searchbar ‘keydown’ event?

    Also, I think I’m gonna try to add buttons (they’re all the same, with the same function) to a small column by the side of every row. Is there an easy way to add buttons to the table?

    And another misc: can I start the table with a header’s filter? (i.e with a click on a header).

    Thanks in advance,
    Tiago Magnus

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    thanks for your question, and sorry for the trouble.

    With the keydown, you are on the right track.
    I think that you will only need something like

    jQuery( ".tablepress-1_filter input" ).keydown();
    

    to trigger the event (after setting your value).

    For the buttons: No, this will need custom code as well. You should select all rows with jQuery, then loop through them and use e.g. append() or similar to add your button (which you also create as a jQuery element).

    For the last question: I don’t really understand what you mean here. Can you explain that more?

    Regards,
    Tobias

    Thread Starter tiagomagnuss

    (@tiagomagnuss)

    Hey, thanks for the quick answer.

    Yes, it worked also with the ‘keyup’ (I tried “.trigger(‘keyup’);)

    Okay, will find a way for it.

    Sure! When you click a table’s column header, it filters the table on ascending/descending order by the clicked header’s tag. I’d like to do this when the page is loaded, i.e: my table is from start filtered by the 1st colum.

    Thread Starter tiagomagnuss

    (@tiagomagnuss)

    Also, do you know where the size(width, height) of each column are defined?

    And I’m making just a page of a website with your awesome plugin, which helped me a lot. I’ll remember to put the credits on it!

    • This reply was modified 7 years, 9 months ago by tiagomagnuss.
    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    good to hear that this worked!

    Ah, you mean sorting and not filtering ??
    To have an initial sorting, you can use a “Custom Command” on the “Edit” screen of the page, like

    "order": [[ 0, 'asc' ]]
    

    This would sort the table for the first column in ascending order, on page load. Counting the columns starts with 0 in the code. For details, see https://datatables.net/reference/option/order

    For the width/height: That’s basically determined by the browser, based on the content in the cells, and on CSS. To influence the width, you could e.g. use https://tablepress.org/faq/column-widths/

    Regards,
    Tobias

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Filter function & Buttons’ is closed to new replies.