Looping through rows - dart

I have an app that displays a number of rows of products. Right now it's hardcoded to use three html rows. I really want to build a template for one row, and loop through and populate as many as I need to show up. I was thinking this is a job for Web UI loops (think fruitsearch example). Or do I want to build the template and make it a web component and pass my data to that? I'm really not sure what the best structure is here. This is a bit of an open-ended question, but what's the ideal structure for populating multiple rows of data?

Use Web Components when you need re-usability, or if your rows have complex logic or layout associated with them.
Given your description of "rows of products" I would use a Web Component for each product row and possibly another Web Component to keep track of all the product rows. For instance, if this is a product search result page, the SearchResultComponent could have a title, a list of ProductRowComponents and the number of results found, and each ProductRowComponent could have a name, a price and an image.
This would make it easier to handle the complexity involved as well as allow re-usability (i.e. using multiple ProductRowComponents).

Related

User input in repeated grid to fill dynamic dropdown

I am building an Orbeon form where people can add information to a repeated grid, e.g. Name, Age.
Later in the form, there will be a 'Friend' section that will reuse data from the repeated grid.
I can synchronize the data using <fr:synchronize-repeated-content>, but is it possible to reuse the data from the repeated grid in a dynamic dropdown instead?
A dynamic dropdown could make this form much shorter, compared to <fr:synchronize-repeated-content>, as only a few of the rows in the repeated grid will need more data later in the form (only few friends from a long list of names in the repeated grid).
It is currently not possible for this form to use any web services.
Currently, you can't directly populate a dropdown based on data entered in a repeated grid earlier in the form. As you suggested, using another repeated grid and <fr:synchronize-repeated-content> is a workaround. But being able to directly populate a dropdown would definitely make sense, and this is covered by request for enhancement 4182.

How do i trace multiple XML elements with same name & without any id?

I am trying to scrape a website for financials of Indian companies as a side project & put it in Google Sheets using XPATH
Link: https://ticker.finology.in/company/AFFLE
I am able to extract data from elements that have a specific id like cash, net debt, etc. however I am stuck with extracting data for labels like Sales Growth.
tried
Copying the full xpath from console, //*[#id="mainContent_updAddRatios"]/div[13]/p/span - this works, however, i am reliable on the index of the div (13) and that may change for different companies, hence i am unable to automate it.
Please assist with a scalable solution
PS: I am a Product Manager with basic coding expertise as I was a developer few years ago.
At some point you need to "hardcode" something unless you have some other means of mapping the content of the page to your spreadsheet. In your example you appear to be targeting "Sales Growth" percentage. If you are not comfortable hardcoding the index of the div (13), you could identify it by the id of the "Sales Growth" label which is mainContent_lblSalesGrowthorCasa.
For example, change your
//*[#id="mainContent_updAddRatios"]/div[13]/p/span
to:
//*[#id = "mainContent_updAddRatios"]/div[.//span/#id = "mainContent_lblSalesGrowthorCasa"]/p/span
which is selecting the div based on the div containing a span with id="mainContent_lblSalesGrowthorCasa". Ultimately, whether you "hardcode" the exact index of the div or "hardcode" the ids of the nodes, you are still embedding assumptions regarding the structure of page.
Thanks #david, that helped.
Two questions
What if the structure of the page would change? Example: If the website decided to remove the p tag then would my sheet fail? How do we avoid failure in such cases?
Also, since every id is unique, the probability of that getting changed is lesser than the index being changed. Correct me, if I am wrong?
What do we do when the elements don't have an id like Profit Growth, RoE, RoCE etc

Creating Dynamic Sheet Cell Reference List for pulling numbers to SUM

I've been working on building a data analysis sheet, which is quite verbose at the moment and a bit more complicated than it should be as I've been trying to figure this out. Please note, I work doing student data in a school.
Basically, I have two sets of input data:
Data imported from a CSV file that includes test data and codes for Common Core Standards and the questions tied to those standards as a whole class summary
Data imported from a CSV file that includes individual scores by question
I am looking to construct 2 views:
A view that collates and displays data of individual standards per student that includes a dropdown to change the standard allowing a teacher to see class performance by standard in a broad view. The drop-down is populated dynamically from the input data (so staff could eventually dump data and go directly to reports)
A view that collates and displays data of individual students broken down by performance on each standard allowing a teachers to see the broader spectrum for each student. The student drop-down is populated from Source list 2.
I have been able to build the first view, but am struggling with the second. I've been able to separate the question codes and develop strings of cell references to the scoring data, including a dynamic reference to the row the selected student's score data appears on in the second source set from above.
I tried to pass through an indirect() formula into a sum() so as to process for a mean evaluation, and have encountered errors. I think SUM() doesn't process comma-separated cell reference lists from Indirect() [or in general] or there is something that I am missing to help parse it. Here is the formula I have tried:
=Sum(vlookup(D7,CCCodeManip!$A:$C,3,false))
CCCodeManip!C:C includes the created text (based on the dynamic standards and question codes, etc), here's an example of what would be found there:
'M-ADI'!M17, 'M-ADI'!N17, 'M-ADI'!O17, 'M-ADI'!P17, 'M-ADI'!Q17, 'M-ADI'!R17, 'M-ADI'!J17
I need these to be dynamic so that teachers can input different sets of standards, question, and student data and the sheet automatically collates and reports it in uniform ways (with an upward bound of 20 standards as I currently have it built)
Here is a link to the sheet I built, with names and ID anonymized. There's a CRAP TON of sub-tabs, and that's really just being able to split apart and re-combine data neatly without things error-ing out due to data overlapping, aside from a few different attempts and different approaches to parse the cell reference strings.
The first two tabs are the current status of the data views. I plan to hide a bunch of the functional stuff that is there to help pull data accurately.
The 3rd and 4th tab are the source data sets. 5th is a modified version of source data that allows me to reference things better, and I've tried to arrange the sheets most relevant towards the front of the set.
https://docs.google.com/spreadsheets/d/1fR_2n60lenxkvjZSzp2VDGyTUO6l-3wzwaV4P-IQ_5Y/edit?usp=sharing
Some have a different approach? I am aware that I might be as far as I cn go with this and perhaps should consider scripts - my coding experience is a bit out of date and my strength is more with the formulas, but I can dig into things with some direction, if anyone can help.
Ok so I noticed something.
It seems the failure is in the indirect reference:
=indirect(CCCodeManip!C3)
The string I am trying to parse via indirect is going to be generated into something like this, dynamic from reference to other data:
'M-ADI'!M17, 'M-ADI'!N17, 'M-ADI'!O17, 'M-ADI'!P17, 'M-ADI'!Q17, 'M-ADI'!R17, 'M-ADI'!J17
The indirect returns the error that the above string is not a cell reference with the #REF code.
Can someone give me a clue as to what is causing this? I am going to dig into the docs on Indirect() from google and will post anything that I find.
Perhaps it is that indirect() can't handle lists, but only specific references and arrays, which may require me a to build a sheet to do the SUM formula on for each question set (?)
So I think I figured it out, but i Ended up parsing the data differently, basically doing the sum based on individual cell references and a separate sum formula, bypassing the need to do it all at once, it jsut makes my sheets a lot dirtier! I am eventually going to see if code could do it better if I need to, but this is closed for now.
Basically, I did individual cell references to recall scores in a row, then used a separate SUM formula, and created references / structures to be able to pull those sum() results. Achieves the same end, but with extra crap on the sheet.

How to auto populate specific Google Form fields, based on dropdown choice

I use Google Forms regularly at work, and I think they are awesome, especially since I am a total newbie with coding. With a few good plugins for Forms and Sheets, I am able to generate contracts, invoices, and so on very easily, based on document templates.
To keep it short, here is my request:
I have a form, where I input the customer's details, and upon submission, an addon generates a gdoc, based on a template. Al working great so far. My problem is that we are generating many different documents for a single customer, so it becomes a repetitive and very time-consuming task, considering that I have 15-20 different input fields for a customer, plus specific input fields for each different document.
The first input filed in my form is "Customer Name" and I have managed to create a dynamic dropdown list, that takes it's information from a specific column in a Google Sheet.
My request: how could I auto populate specific input fields in my Google Form, so that, based on my dropdown choice, the auto completed information will match the corresponding row present in the Google Sheet.
I have attached 2 images for easier understanding:
You can actually do this with a simple vlookup:
note: I also always wrap my functions with and if statement that checks if there is text in the first field, so try:
pretend that your dynamic customer name is in cell A1:
customer vat formula -
=IF(ISTEXT(A1),VLOOKUP(A1,'Parteneri'!A:C,2,FALSE),)
customer city formula -
=IF(ISTEXT(A1),VLOOKUP(A1,'Parteneri'!A:C,3,FALSE),)

Automatically updating Data Validation lists based on user input

I have a very large data set (about 16k rows). I have 10 higher level blocks and within each block I have 4 categories (10 rows for each) which use Data Validation lists to show items available in each category. The lists should automatically update based on user input. What I need your help with is that I want to use the same data set for each block and preferably a least calculation/size intensive approach. I have put together a sample file that outlines the issue with examples.
Sample File
Thank you for your help in advance.
Okay, I've found something, but it can be quite time consuming to do.
Select each range of cells. For instance, for the first one, select B3:B18 and right click on the selection. Find 'Name a Range..." and give it the name "_FIN_CNY". Repeat for all the other ranges, changing the name where necessary.
Select the first range of cells to get the data validation, and click on "Data validation", pick the option "Allow: List" (you already have it) and then in the source, put the formula:
=INDIRECT($G$4&"_CNY")
$G$4 is where the user will input. This changes as you change blocks.
_CNY is the category. Change it to _CNY2 for the second category.
Click "OK" and this should be it. Repeat for the other categories.
I have put an updated file on dropbox where you can see I already did it for the data of _FIN for categories CNY, CNY2 and INT and did the one for _GER as well. You'll notice the category of INT for _GER doesn't work, that's because the Named Range _GER_INT doesn't exist yet.

Resources