Hello!
I am querying sql data using xbasic because I cant get the query to work in the normal components (alpha doesn't seem to like some of the syntax)
I got the query working using xbasic, and I'm getting the data I want from it, which is a varying sized list of pricing data that changes from product to product.
The issue I'm having is taking this varying sized list of data and putting it onto the UX for the user to view. I have a half working xbasic function that tries to populate an empty repeating section with the rows from the data, but I am only getting the first row of data and nothing after it, and when I click on a new product it doesn't update with the new products data, it still has the data from the old product.
Is there an easier way to do this? I just have a JSON with data and I want to show that data in rows on the users screen, but each product may have a different number of rows and I'm not sure what the easiest way to do this is.
Here is where it is at currently. I have broken it a little with some recent changes by taking out some of the repeating section modifying functions. I'm wondering if theres an easier way to show this data than using and manipulating a repeating section? I see this dialog object setListColumnsAndPopulate but I haven't had success with it yet.
Here is the data I am trying to put into rows
If someone could point me in the right direction that would help me out a lot. I seem to be running in circles now. Should I just build an html table and set the innerHTML of a div to that data?
I am querying sql data using xbasic because I cant get the query to work in the normal components (alpha doesn't seem to like some of the syntax)
I got the query working using xbasic, and I'm getting the data I want from it, which is a varying sized list of pricing data that changes from product to product.
The issue I'm having is taking this varying sized list of data and putting it onto the UX for the user to view. I have a half working xbasic function that tries to populate an empty repeating section with the rows from the data, but I am only getting the first row of data and nothing after it, and when I click on a new product it doesn't update with the new products data, it still has the data from the old product.
Is there an easier way to do this? I just have a JSON with data and I want to show that data in rows on the users screen, but each product may have a different number of rows and I'm not sure what the easiest way to do this is.
Here is where it is at currently. I have broken it a little with some recent changes by taking out some of the repeating section modifying functions. I'm wondering if theres an easier way to show this data than using and manipulating a repeating section? I see this dialog object setListColumnsAndPopulate but I haven't had success with it yet.
Code:
function updateListPrices as C (e as P)[INDENT]debug(1) dim jsToReturn as C = "" 'Loop through all data and set it to each row if e.dataSubmitted.id != "" then[/INDENT][INDENT=2]dim data as P = json_parse(SQL_getListPrices(convert_type(e.dataSubmitted.id, "N"))) dim index as N = 1 FOR EACH listprice IN data[/INDENT][INDENT=3]if (variable_exists("data[index].price")) then[/INDENT][INDENT=4]dim price as N = round(convert_type(data[index].price, "N"), 2)[/INDENT][INDENT=3]else[/INDENT][INDENT=4]dim price as C = "Error"[/INDENT][INDENT=3]end if if (variable_exists("data[index].unit")) then[/INDENT][INDENT=4]dim unit as C = convert_type(data[index].unit, "C")[/INDENT][INDENT=3]else[/INDENT][INDENT=4]dim unit as C = "Error"[/INDENT][INDENT=3]end if jsToReturn = jsToReturn + "{dialog.object}.setValue('price:" + index + "',\"" + convert_type(price, "C") + "\");" jsToReturn = jsToReturn + "{dialog.object}.setValue('unit:" + index + "',\"" + unit + "\");" index = index + 1[/INDENT][INDENT=2]NEXT[/INDENT][INDENT]else[/INDENT][INDENT=2]'clear all rows jsToReturn = jsToReturn + "{dialog.object}.setValue('price:" + 1 + "','');"[/INDENT][INDENT]end if updateListPrices = jsToReturn[/INDENT] end function
Code:
{ { "price": "3.50", "unit": "each", "effective_date":"1/20/2021 }, { "price": "48.70", "unit": "case", "effective_date":"1/21/2021 }, }
Comment