How to select multible rows in a table

Has anyone done that or planing to do it and want to share his experience?
i want to select multiple rows in a table and preform server side operations on them for example.

I need a feature where a user can select multiple items from a list of search results and print them out, or, ideally, email themselves the selected items.

I’ve added an event to items in the list using:
dmx-on:click="cookies1.set('idlist',stock_id + " " + cookies1.data.idlist,{});serverconnect2.load({})"
This creates a space-separated list of ids. (It also loads a new query, using the list as a search parameter, but adding this step at this stage is partly for debugging purposes.)

Then, in query builder, I use the cookie in the condition like this:
(WHERE) stock_id IN {{$_COOKIE.idlist.trim().split(" ")}}

I hope this helps. I think it will work for my needs. However I haven’t found a way to assign the query results to a variable and incorporate them into an email. I don’t know if it’s possible but I would be very grateful if someone could tell me.

2 Likes

Hi @mrbdrm, you probably going to hate this solution, but it is what i have had to do before.

I had a table of items and each had a checkbox to the left of the row.

I created a MySQL table just for storage of the selected values, so when a user checked a row as a selection it wrote a line in the table, this had the products primary key as well as an identifier which was the logged in users id. If a user deselected a row in their selection then it removed it from the table.
When the user submitted their selection, it just queried the temporary storage table and pulled all the info, then it wrote all the new data to the correct table, and deleted all the temporary data just created.

Thats the easiet method i could come up with for my needs anyway.

@psweb your solution reminded me by the visual basic days :joy:

Lol, sometimes the simplest solutions work best, haha. Good Luck

1 Like

Usually you do this indeed with a checkbox per row. Just make sure you give all the cheboxes the same name. This way it will become a single array variable containing the selected values.

You can use the variable later on to submit it to server action and use it in queries like IN filter.

Or do client side data formatting and filtering with it.

1 Like

2 posts were merged into an existing topic: Serialize and unserialize