• Resolved 0cg0

    (@0cg0)


    Good morning Tobias,
    sorry for the trouble. I would like to ask you if there is a way to perform a custom search on the table.
    In practice I would like to be able to search only in the values ​​of the first column and only for the exact match of the entire contents of the cell.

    For example: in the first column I have a 10-character alphanumeric code (e.g. 01234A67B9), I would like the search (without acting on any other column) to return the corresponding record only if the user has written all 10 characters of the cell of the first column.
    Basically if you have written <= 9, no record must appear.
    Thanks.

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    I see what you mean, but unfortunately, I’m not aware of an easy way for this that uses the JavaScript search feature.

    However, you could maybe use the TablePress Row Filter Extension from https://tablepress.org/extensions/row-filter/ with some tweaking: Instead of setting the search term via the Shortcode parameter, you could let that come from a URL parameter, via https://tablepress.org/extensions/shortcode-filter-get-parameter/ Then, a small custom search form (from HTML code) could add that filter term to the URL.

    Regards,
    Tobias

    Thread Starter 0cg0

    (@0cg0)

    Thanks Tobias,
    it is a possibility, but unfortunately it is not a viable solution for me, because through the GET URL the user can query the whole table.

    I am already testing with another table this type of shortcode invoked with a GET, [xxx_table_cell id = 123 column = 2 /] and it works fine.
    I only have 2 problems:
    1. the whole table is exposed (just change the GET parameter in the URL);
    2. if the user writes in the URL a GET parameter that does not exist in the table, in the frontent the schortcode is resolved with an error string (type [table “123” does not have that cell /]).
    I’ll do some testing, if you have any other suggestions it would be greatly appreciated.
    Thanks again.

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    no, with the GET parameter, you could protect against showing the full table. You would just have to set the filter_full_cell_match=true Shortcode parameter.
    It’s actually much easier to get all data with the JavaScript filtering, because the content is in the HTML code already.

    The TablePress Single Cell Extension can not be used for actual filtering, so that I don’t really think that it will help here.

    Regards,
    Tobias

    Thread Starter 0cg0

    (@0cg0)

    Hi,
    as for the content in the HTML code, I solved it with a trick: the first record of the table is empty and I set the pagination to only 1 record, in this way no data is loaded.

    For the “filter_full_cell_match = true” parameter I have to do some testing combining with a GET call.

    Do you have any idea to manage the printing of the not found in the shortcode?

    Thanks

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    yes, but if someone now turns JavaScript off or looks at the HTML source of the page, he will see all table rows, regardless of pagination.
    In the end, it depends on how much you really need to protect your data.

    For the “Not found”: No, sorry, I don’t have a solution for that at the moment 🙁

    Regards,
    Tobias

    Thread Starter 0cg0

    (@0cg0)

    Hi,

    this is the source of my table:

    <tbody class=”row-hover”>
    <tr class=”row-2 even”>
    <td class=”column-1″>-</td><td class=”column-2″>-</td><td class=”column-3″>-</td><td class=”column-4″>-</td><td class=”column-5″>-</td><td class=”column-6″>-</td><td class=”column-7″>-</td><td class=”column-8″>-</td><td class=”column-9″>-</td><td class=”column-10″>-</td><td class=”column-11″>-</td><td class=”column-12″>-</td><td class=”column-13″>-</td><td class=”column-14″>-</td>
    </tr></tbody>

    Nothing is loaded!
    Or am I missing something?
    Thanks

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    Is this from the “View Source” feature in the browser? Or copied from the developer tools?

    Regards,
    Tobias

    Thread Starter 0cg0

    (@0cg0)

    Hi,
    you are right in the source there is the whole table.
    Too bad, I was thinking of using Tablepress as a db to characterize one parameter of a single Woocommerce product, instead of creating thousands of identical products.
    Thanks again.

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    I think you can do that, but with the approach with the Row Filter Extension and the Shortcode Filter from GET parameter Extension.

    Regards,
    Tobias

    Thread Starter 0cg0

    (@0cg0)

    Hi,

    ok, I’ll try.
    Thank you

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! 🙂

    Best wishes,
    Tobias

    Thread Starter 0cg0

    (@0cg0)

    Hi,

    I wanted to update you.
    The Row Filter Extension mechanism with filter_full_cell_match=true + GET works.
    Only the affected record is loaded.

    I had to add a mechanism to prevent the table from being invoked without a valid GET, because otherwise all records are exposed in the source.
    Thanks again for the tip.

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! 🙂 Good to hear that this helped!

    Best wishes,
    Tobias

    Instead of predefined in the shortcode to pass the parameter and return that data records. Example [table id=1 filter=”0000001335″ /] and URL return https://mywebpage/?table_filter=1234

    Can it be done without pre-defined parameters in the shortcode?
    So user looks for keyword 14567, so they just change in url something like this https://mywebpage/?table_filter=14567

    • This reply was modified 4 years, 1 month ago by tmz1001.
    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.
    Also, sorry for the late reply. I was very busy with personal life, so that I could not reply earlier.

    That’s what the TablePress Extension from https://tablepress.org/extensions/shortcode-filter-get-parameter/ that is described above can do 🙂

    Regards,
    Tobias

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘Custom search’ is closed to new replies.