I have added a table to my dynamic page. I want that table to be filtered using the information from a text box (which is fed data from the dynamic collection).
My code is as per below:
import wixData from 'wix-data'; $w.onReady(function () { //Get records with text link to title. $w("#dataset1").setFilter(wixData.filter() .eq('test_clientvisits_charterer', $w('#CName').text ) ); })
The table is empty though, what am I doing wrong?
If I replace "$w('#CName').text" with the actual content of the textbox, the table displays the correct data.
I agree, I think the problem was that the dataset was not ready! Thanks for your quick response though, really appreciate the work you guys are doing.
Hmmm...
Ah - good for you! Don't know why I didn't think about the dataset.onReady(). That's certainly the main part of the problem. If the dataset isn't ready, then the text field hasn't been set yet either.
In any case, glad you figured that out.
Yisrael
Hi Yisrael, thanks for your comment.
I tried inserting .value but it displays an error and does not let me. I managed to fix it using the below code:
import wixData from 'wix-data'; $w.onReady(function () { $w("#dynamicDataset").onReady(()=>{ const tagName = $w("#dynamicDataset").getCurrentItem().test_charterer_name; $w("#dataset1").setFilter(wixData.filter().eq("test_clientvisits_charterer",tagName)); }); });
If you're really using a textbox, then it should be $w('#CName').value