Sorting database

I am trying to show a database entry on a page. The entries (rows) include a “year” column (going from 1925 to 2018). I can SORT the database by the year, but the sorting 1) is not displayed on the site, and 2) does not get retained by the database. For whatever reason, the database reverts back to 1983 as the first row. I have made changes in Sandbox before Sync, and I have made changes to the Live database; each time I have pressed save. I have also clicked on “Edit Live Database”; here the sorting is correct and stays correct. However, when I go back to sandbox/live, the rows have again rearranged; starting with 1983.

1 Like

Ben, I am not quite sure if I understood you correctly, but are you sure you are not mixing up a collection with a resultset (queryresult). The first is the raw, underlying database in an unsorted way, the second is the result of a query, sorted how you want. This is a COPY (more or less) of the DB and the DB itself will not be sorted.

Giri, thanks for writing. Ok, I think that I understand. However, I am not sure that I have discovered in Wix how to get a search result from a DB to show up in a table form. When I insert a table (Insert: lists and grids), the only choice I have is to “Connect to Data”. This choice allows you to specify which DB and which columns. No other options are visible. How would I show the results of a query instead? I am sure that this is easy, but being 48 new to Wix, it is escaping me.

Ben,

check out gallery to display the results and Displaying Database Content on a Dynamic Item Page | Help Center | Wix.com to display a single result for further details. another cool option is using https://support.wix.com/en/article/about-repeaters it will make your site more stunning than a simple table result. you can use code to create whatever you want given the ability to query your db and use display components

good luck!
Shlomi

Shlomi…how do you get a search box to work with repeater? I have tried using code as shown in a tutorial video, but as soon as you type in a search, the repeater disappears with no results showing…and no idea how to use a simple box and button approach.

This is the code I tried to use:
https://www.youtube.com/watch?v=Hx7_8-lRsW0&feature=youtu.beI

can you share your site and where you got so far?

Shemesh, here is link to page: https://www.ourozarks.com/Ozarks

Here is code thus far:
import wixData from “wix-data”;

let debounceTimer;
export function iTitle_keyPress(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w(“#iTitle”).value);
}, 200);
}

let lastFilterTitle;
function filter(title) {
if (lastFilterTitle !== title) {
$w(“#Ozarks”).setFilter(wixData.filter().contains(“Place”, title));
lastFilterTitle = title;
}
}

And here is screen shot of database. Have reverted to simplicitiy to try to work the bugs out and connected only the Place column. I have found that by deleting ! in the conditional expression highlighted below, it takes away the blanking out of results, but it actually then gets no results. Leaving code as == shows a hint that expect ===, but replacing with === gets no results and leaves screen as is. So guessing somehow everything tied to this line or other line of filter. But their code seems to work fine at this point of tutorial.
if (lastFilterTitle !== title) {


The warning is Parameter event is never used (their code has this showing as well at that point). The only thing I can think of is how they have their repeater set up…like so many of these tutorials, they do not show the “pre-setup”…they already have buttons and repeater in place. So a setting off? They have a connection in place that I do not. I have tried also connecting to datasets, not connecting, etc in an attempt to replicate to no avail. I used repeater from the List & Grid add an item. It appears to be one they used…but?

Layout of page in editor

Since writing this, have done some more playing around. Changed the id of the textbox that connects to Place. It had id of text17. I changed to place thinking perhaps that was where supposed to read. When I went to search, it no longer disappeared but no results. Changed all back, but now staying as not blanking out, but no results being made per search. Have to start believing the issue may be with the repeaters provided in Lists & Grids not playing nice with code?

Hi,

thanks for sharing. the issue turned out to be quite simple - the use of the column display name rather than its key. another thing is the use of the component value (text) and not the component for the query filter

export function button2_click(event, $w) {
	console.log($w("#iTitle"));
	$w("#dataset1").setFilter(wixData.filter().contains("title", $w("#iTitle").value));
}


good luck,
Shlomi

Shlomi, you are showing a click event rather then keyPress as I am trying to use

Oh my…that fixed it!!! Appreciate this so much!!! and yes, works as keyPress!! I really could add a few more !!!

Jeff,

there is currently a known issue with onkeypress value used for filtering, until we resolve it, please prefer the search button

shlomi

onkeypress working for this wonderfully

Jeff,

works because of the throttler you set up, glad it is working for you :wink:
regarding the image click, it is a bit hidden but where you connect the image to data you also have link to…
choose your dynamic page of the single item

good luck,
Shlomi

Realized my error as soon as I clicked out…tried to do delete that comment but too late. Loving the search I have set up.

If you happen to know…if a person has several options available but want to show only those inputed how?
Example: colors blue green yellow red
Person in form input selects blue yellow that goes to database fields for each. But in profile you only want it to show the blue yellow, without the loss of space of a spot for green and red…in other words a continuous list.

Hi Jeff,

the example you gave uses terms too specific to your domain, can you please elaborate some more. i didnt understand what you are trying to achieve

Shlomi

Shlomi,
I believe I figured out how to make this work by creating a field that the person can enter their own info (but do so with preferred terminology list. I want to show on a profile or dynamic page the choices they have made, be searchabe…but to set up a separate field for each causes an issue in setting up the field on dynamic pages…if they choose only nonfiction and horror, then you have blanks showing where historical fiction, romance and true crime fields are…unless way to have some sort of generated field based on form input that takes out the blanks so you can have one searchable field that has all the terms chose listed and not the ones they did not chose.


On side note, when you set up a dynamic page for member profiles (set to public viewing), and your dynamic page url is set with ID on end…is that a clickable/searchable link in search engine?