Hey all,
I've been trying to get this to work but it has proven to be more complex than anticipated..
As it stands, the process should be as follows:
User inputs info into userinputbox [gameTitle_keyPress] -> code to check database [emu_gamebugs] -> match name with existing name in database [title]-> copy contents from richtext column [para1] -> past result into richtext box [gameTitle]
--
import wixData from "wix-data"; export function gameTitle_keyPress(event) { wixData.query("emu_gamebugs") .eq("title", $w("#gameTitle").value) .find() .then((results)=> { let item = results.items $w("#gameTitle").value = item.toString(); }); }
--
As it stands, I can't solve where to insert copy contents from richtext "para1" column in database & i'm not convinced my last part will work as well since I can't test it.
I genuinely searched for similar issues and read API examples but couldn't find one that really guided me properly through all these steps.
Any help is much appreciated.
Thanks!
Can somebody show me a generic working example so I can better understand how to integrate @Yisrael (Wix) comment?
Thanks in advance
I searched in the API library for similar examples and in the forums without success. Do you know a similar case or anything that I could use as a reference? This is my first time venturing in this territory via WixCode... Thanks for your time 😅
Hey,
For some reason it stopped working entirely; in the sense that it's not longer even returning the right "title" (I search for "A" -> Press "A" on displayed table #gamebugTable -> Displays "B") and the console #gameTitle and throws the following error:
" Wix code SDK Warning: The value parameter that is passed to the value method cannot be set to null or undefined. " - Line 108 [which is located here @ let item = results.items[0]; $w("#richTextBox1").value = item.desc1; ]
I guess it was never working since it was always returning the first entry found-match which was the latest and I assumed it was working since that's the one I was hoping it would display -_-'
I just can't see anything wrong but I'm hoping I'm just blinded and someone will point something off..
--
import wixData from "wix-data"; export function gameTitle_keyPress(event) { wixData.query("emu_gamebugs") .limit(9) .contains("title", $w("#gameTitle").value) .find() // Run the query .then(res => { $w("#gamebugTable").rows = res.items; $w("#gamebugTable").expand(); }); }
$w.onReady(async function () { $w("#gamebugTable").columns = [ { "id": "title", "dataPath": "title", "label": "title", "width": 460, "type": "string", }, ]; });
export function gamebugTable_click(event) { //export function gameTitle_blur(event) { wixData.query("emu_gamebugs") .eq("title", $w("#gamebugTable").value) .find() .then((results)=> { console.log(results); let item = results.items[0]; $w("#richTextBox1").value = item.desc1; $w("#gameTitle").value = item.title; $w("#gamebugTable").collapse(); }); }
--
Any help would be appreciated..
I removed the parenthesis and it worked! :D
Thx ^.^
Thanks for replying :)
I've updated the console but it's still not working :/
--
import wixData from "wix-data"; export function gameTitle_blur(event) { wixData.query("emu_gamebugs") .eq("title", $w("#gameTitle").value) .find() .then((results)=> {
console.log(results); let item = results.items[0]; $w("#richTextBox1").value = item.para1(); }); }
--
I'm a bit stumped since the logic is there.. Also, [para1] is the column & field-key name of where the RichText is store in the [emu_gamebugs] database
Exequiel,
You almost have it. A couple modifications, and you'll be there.
First thing to do is to see how the results array is structured. Insert console.log line immediately after the "then" line for that. Then, you need to specify which record from results that the item variable is going to be.
console.log(results); let item = results.items[0];
Then, in the input box assignment line, you need to specify the field (para1 ?) to place in the rich text box:
$w("#gameTitle").value = item.para1;
Also, having code in the keyPress event is going to be problematic. It would have to run that query after every key stroke. Consider putting it into the blur event that fires when the focus leaves the textbox.