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.

1 Like

@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

Hi,

I too am trying to select multiple items from a repeat list and then use the values from each selected item to go into a hidden input field which I can then use to send an email.

So far I have a repeat of machines:

The page has a cookie manager with one cookie called 'quotes'.

Each row has a check box in it, the checkbox has a dynamic event > mouse > click and the action > cookie1.set > quotes > then the vales from the repeated row;

dmx-on:click="cookies1.set('quotes',ref_no+' '+make+' '+model+' '+age+', ',{})"

The button on the top of the page opens a modal with name and email and for now an input (this will become hidden when this project is completed) which I want to hold all the values from the machines selected.

I used the same method as described by TomD but I don't a get list, I only get the last record selected.

Can anyone explain how I get an array of values selected please?

Many thanks
Charles

@cknight why not using a DataStore?
Add a DataStore in your page and on click (button at the top of the page) add a pageflow.run.
Inside the pageflow, add a repeat based on your machines table and check if checkbox.checked then add the current fields [$index] you need in the DataStore...
(pageflow IS NOT AUTORUN)
I hope you got the idea

Think I get it and will give it a try, thank you for the idea.

If you're using checkbox group, you can select the items

image

<form id="form1">
<div class="form-group mb-3" id="input1_group" is="dmx-checkbox-group">
  <legend class="col-sm-2 col-form-label">Some checkboxes</legend>
  <div class="form-check">
    <input class="form-check-input" type="checkbox" value="1" id="input1_1" name="input1_1">
    <label class="form-check-label" for="input1_1">First checkbox</label>
  </div>
  <div class="form-check">
    <input class="form-check-input" type="checkbox" value="2" id="input1_2" name="input1_2">
    <label class="form-check-label" for="input1_2">Second checkbox</label>
  </div>
  <div class="form-check">
    <input class="form-check-input" type="checkbox" value="3" id="input1_3" name="input1_3">
    <label class="form-check-label" for="input1_3">Third checkbox</label>
  </div>
</div>
</form><p>Output {{form1.input1_group.value}}</p>

Then on your server side you can use the split formatter to do whatever you want

2 Likes

Have used a Data Store as described in the article, Creating a Shopping Cart with the Data Store Component and have added a Form Data to get the Data Store data in my server action which is a send mail function.

This is the email I receive;

I have tried formatting the Form Data with the split function by the send function then fails, is there another way to format the Form Data in a more readable form?

Why not send just the IDs of the records to the server side, filter a database query using these IDs and then you can use the array actions to build a list of the records and put it in an email?

I didn't know you could do that and I wouldn't know how to anyway.

How do I filter a database query using multiple ID's, I thought only could be used?

Do I query all records, then use a repeat of that query and then add another all record query inside the repeat with the ID as the condition?

Could you send me an image of the action sequence?

Of course you can filter a query using an array with multiple IDs.
Once you filter the query add the records to an array and use the array value in the email body.
Check the docs about using arrays in server connect:

I have a few questions having followed 'Working with Server Connect Array Lists'

In my case I have a Data Store which collecting for now the following data, Make and Machine ID.

I can output the data from the Data Store in my email as follows:

Datastore: [{"$id":"1","make":"Muller Martini","m_id":"3609"},{"$id":"2","make":"Muller Martini ","m_id":"3511"},{"$id":"3","make":"Muller Martini ","m_id":"3581"},{"$id":"4","make":"Muller Martini ","m_id":"3603"}]

I can only output the whole Data Store from the $post data, if I choose just one variable then I don't get any output, is that correct?

When I add my 'Create Array List' what do I choose regarding the Value and Schema, is it the m_id (machine ID) from the Data Store output?

I have added a database query, is the filter of the query, again the m_id from the Array list above given that is correct?

Thanks for looking, at the moment my final output is a single record so something isn't quite right.

If you already send an array with all the details you need then you don’t need a query to filter and array. I thought you just send some ids…
What exactly do you want to display in the email having this data?

I would just like the data from the Data Store to be in a more readable form for the recipient. I have tried using the split function but the email send then fails.

Ideally I would like:

Muller Martini 3609
Muller Martini 3511
Muller Martini 3581
Muller Martini 3603

So is there a way of formatting the text output from the Data Store?

Hey @cknight ,

I have suggested to use the DataStore because I thought you wanted to show these info in a Dynamic Modal.

For your case (including these info to an email), it is recommented to send only the ids like @teodor suggested.
Then on your api, you add an ArrayList and by creating a query based on the ids, you add in the ArrayList all the info you need.
IF THESE INFO ARE NOT SENSITIVE (because as you know DataStore data can be manipulated by the user), you could send the datastore data as you have it now.

Now. on the email, you can "format" how the email appears to the recepient, only by using inline css rules inside the email content or maybe use an html email template.
For more info please take a look at this article