I have function where results are putted to repeater. Few field are numbers and when i write .text i get error
Wix code SDK error: The text parameter that is passed to the text method cannot be set to the value 0. It must be of type string.K moje pokojeLine 64
i can change it as text and it works but i need it as numbers because later i need to do some sorting as number not text . Can i have text and than change as number somehow? or its solved some other way i can not discover?
function pobierzwolnepokoje(){ getEmptyRooms() .then((emptyRoomsList) => { $w("#repeater4").data = emptyRoomsList; $w("#repeater4").forEachItem( ($item, itemData, index) => { $item(`#text84`).text = itemData.title; $item(`#text86`).number = itemData.g2; $item(`#itext832`).number = itemData.sortowanie; $item(`#text87`).text = itemData.dostawkimax; $item(`#text90`).text = itemData.lokalizacja; $item(`#text91`).text = itemData.uwagi; $item(`#text94`).text = itemData._id; $item("#gallery4").items = itemData.zdjeciepo; } ); }) .catch( (err) => { // console.log(err); }); }
The text element is string based you anything you assign to a text element must be of type string. But you can convert any number to a string object using the below sample code. Good luck.
$item(`#itext832`).number = itemData.sortowanie.toString();
If this is the help you need and my answer was good, please mark it as top comment as it will help others to find the solution.
.or(wixData.query("Agents").contains("daysOnMarket", $w("#searchbar").value)).toString()
i think should be
$w("#searchbar").value.toString() ))
Hey there,
New to coding and wix. I'm trying to do the same but having trouble converting the code you suggested to fit my code. Please let me know if you have any suggestions. The key field I'm trying to convert from number to string object is daysOnMarket. Thank you. Here's my code:
import wixData from "wix-data";
export function searchbutton_click(event, $w) { // Runs a query on the "agents" collection wixData.query("Agents") // Query the collection for any items whose "title" field contains // the value the user entered in the input element .contains("title", $w("#searchbar").value) .or(wixData.query("Agents").contains("commission", $w("#searchbar").value)) .or(wixData.query("Agents").contains("ofListingPrice", $w("#searchbar").value)) .or(wixData.query("Agents").contains("daysOnMarket", $w("#searchbar").value)).toString() .find() // Run the query .then(res => { // Set the table data to be the results of the query $w("#table1").rows = res.items; }); }
Works Thank You