How can I display the default value of the row in Listview?

I'm trying to display the percentage value as a default value in the web application, which is retrieved from the database by ID. However, I'm facing an issue where it displays the value of the ID in the first row.

My sql code(query1) :

SELECT
*
FROM
CLIENT.EntryCategory
WHERE
CategoryID = {{ editableText2.label.substring(0,2) }};

default value for each row: {{query1.data.percentage}}

the value of editableText2.label.substring(0,2) should be in every row different but it isn't.

Hey @MC123! You can reference the specific row in a List View using the index property. There are some docs here that explain it better than I can:

https://docs.retool.com/docs/create-custom-list-views#the-i-variable

But please do let me know if you have any questions! Happy to help you get this set up.

Hey @victoria

I tried it with 'I' but it didn't work because He displayed the result only in sequence and not next to the correct element . I Solved the Problem with a JS transformer:

I compared 2 Object with each other and added them to an object.

Example

let result = {};
let count = {{ checkboxGroup3.value }}
let object = {{query36.data}}; [Event.ID,Event.Name]
let object1 = {{query37.data}};[Event.ID,Event.Percentage]

for (let i = 0; i < count.length; i++) {
for (let j = 0; j < count.length; j++) {
if (object.ID[i] === object1.EventID[j]) {
const key = object.ID[i];
const value = object1.Percentage[j];
result[key] = value;
}
}
}

return result;

However, I am still open to better solutions, as I am concerned that this solution may slow down my app

Hey @Victoria ,

Thank you for your Support and sharing your experience, do you maybe have a smarter solution than how i did in my Code above?

Many thanks for your time.

Hi @MC123!

So sorry for the delay here, let me take a look :slightly_smiling_face:

I took a look at your code and wanted to clarify your use case! It sounds like you have data coming from two different tables and want to match the data by ID and EventID? If so, would writing this logic using SQL JOINs work instead? It's generally better to write this sort of logic at the server level rather than at the client level (basically, you want to pull as little data into Retool/the browser as possible so your SQL queries should do as much pre-filtering as they can).

Sadly. there is no possibility ( I think) to write this logic in SQL because the data coming from 2 different Database sources. the first one is from a Mysql DB and the second one MSSQL DB

Ah, got it! Would our "Query JSON with SQL" query type help at all? It would let you write SQL against two different queries :slight_smile: