I am in the process of creating a very basic to-do list so that I can slowly learn the functionalities of WeWeb and Xano. So far I have achieved the followign:
Pull a collection from Xano onto a table in WeWeb
When user checks/unchecks the checkbox next to a to-do task, the backend table in Xano gets updated. Iām able to achieve this by using a workflow which is attached to the checkedbox element.
Now, I want to achieve the following:
When the checkbox is checked (i.e. when value is true), I want the entire row to move to the bottom of the list
If the user unchecks the checkbox, the entire row should move back to itās original position
Good news! I was able to sort of achieve what I wanted to achieve using filters when Iām binding the collection to the table. Hereās what I did:
I created another collection below the first collection
In the first collection I added a filter when binding, with the condition that it should display only those items whose chechbox value is āfalseā
In the second collection I added a filter when binding, with the condition that it should display only those items whose checkbox value is ātrueā
To some extent it worked. BUT, if I checkbox one item, another random item from the first collection shows as checked. However, in the database, the correct values are getting recorded. For example - if there are three items - item_1, item_2 and item_3, and I check item_1, item_1 gets filtered correctly and the database in the backend shows that item_1 has a value ātrueā. However, in the frontend, item_3 also shows as checked but in the backend, item_3 still holds the correct value of āfalseā.
Hereās a link to a Loom recording. Unfortunately my mic wasnāt working and I couldnāt record the audio. Hopefully it can help -
Why not just sort the collection input by the value of your true_false column?
You could apply the same logic like @Joyce is using here, but without binding the value and by just simply sorting it by a static condition.
Or directly sort it in Xano. Btw, you also need to bind the checkboxes to your checked/unchecked value.
Sorting did help. And I was able to get the condition right. However, in preview mode, when I am checking the checkbox, I face the same issue as you can see in the Loom video I attached in my previous message. A random item gets checked in the frontend, without the corresponding value changing in the backend. So far, Iāve been able to achieve the desired condition using sort as well as filter. But I think this is a front end bug. Any idea how I can go about the front end issue?
I could be wrong but I think Iām doing that. Hereās a step by step:
User clicks on the checkbox in the frontend
Workflow step 1 - calls Xano api and updates the record in the backend.
Workflow step 2 - fetches the collection again
If I donāt add the sort or filter condition to the collection, everything works exactly as I want. The moment I add any kind of sort or filter condition, the front end produces erratic behavior. I even applied sorting logic in Xano backend api call to fetch collection without any front end filters or sorting and the same issue is happening. Below is a loom of what Iām facing. This is with backend api sorting the collection. No filter/sort in the frontend.
Can you send how the data is bound? I need to see how you determine the checkbox being selected from the backend into your checkbox. Iām 90% sure you have it wrong. Thats what Iām telling and asking you all the time
You might want to set your checkbox value to a dynamic value from the context, now itās gonna be always false. As you seem to be referencing todo.data[0] ā fixed index
For the checkbox element, I have craeted two states. One is the default one and the other is checked. In the ācheckedā state, in the āconditionā section, I have binded it using the formula item.data.complete=true
Hey! I just managed to resolve the issue. I deleted the entire table and started from scratch and now itās working
I donāt know what went wrong here, but its working now.
Thank you so much Broberto for pointing me in the right direction, especially with the sort and filter function. I learned a lot in the last few hours thanks to you