how to access custom row(s) data via Alloy? - titanium

ive tried many/multiple ways to get this to work but just cant as yet, so would appreciate anyone's assistance.
i have a view as follows :
"LBProw.xml"
<Alloy>
<TableViewRow id="LBProw" >
<ScrollableView id="sView" >
<View id="view1" >
<!-- text labels on the row -->
<Label id="LBPheading" > </Label>
<Label id="myLabel1" > </Label>
<Label id="myLabel2" > </Label>
</View>
</ScrollableView>
</TableViewRow>
</Alloy>
adding rows to the table is working 100% fine.
what i cant work out, is how can I loop through the previously created tableview rows, access the rows (custom) fields values, and then do something with those values. I need to access these rows (and their custom row fields values) from a different JS file.
eg. somelogic.JS <--- loop thru the table view rows, retrieve the rows custom field values and then use those values (note that $.myTable is directly accessible from this JS file)
as an example, i tried using the following but could not work out how to get the individual rows custom fields values (the label values for "LBPheading", "myLabel1", "myLabel2")
// loop thru the rows
for (i = 0; i < $.myTable.data[0].rows.length; i++) {`
Ti.API.info('row #' + i);
?? $.myTable.data[0].rows[i].???? <== how can i get the rows (custom) field values ?
}
I think, it has to do with the embedded ScrollableView and View in the row ? but I cant figure out how to reference the Label(s) within that structure.
Really appreciate any assistance/advice.

IMHO you are doing it the wrong way, the UI is just for presentation and you should keep track of the model associated with each row. When the user selects a row, query the collection and retrieve the associated model... that should contain the information you are looking for

Here is a good example for you to refer to. It is made in Alloy, custom rows, and dynamic updates to the tableview.
http://docs.appcelerator.com/titanium/latest/#!/guide/Alloy_Samples-section-37535160_AlloySamples-TodoList

Related

How to loop for each record in One2Many field in form view to create dynamic elements?

I have a customized One2Many field that contains several records for this current data.
I am working on a form view.
I need to construct something like this: (I don't want a tree)
<for every record in one2many_field>
<button something...>
</for>
I only want the result as to create 1 button per record in the one2many_field and be able to get the data in some fields from the model of the one2many_field too.
Is there any way to achieve it? I have searched for some time but found nothing even remotely close to this requirement.
You won't be able to achieve that in a Form View. Views in Odoo are kind of strict but it's mostly to avoid bad stuff to happen.
Anyway, you could think about re-creating the full view by yourself using QWeb View (doc for v14 here)
If you want to keep your Form View, you'll have to use a tree inside the form.
Know that you can totally add buttons in Tree views like adding on a sale.order.line something like <button class="btn btn-primary" type="object" name="product_id_change" string="Force Product Id Change"/> (useless, just for the example)
Check example image here
And play with some attrs to change the visibility of fields...
Hope it helped :)

Vue 2 - How / is it possible to create a unique layout during a v-for loop?

I am trying to create a questionnaire. I have an array of questions. Each question is an object. During the loop the <component :is> checks the component property inside the question object. If the property equals an Input for example then an input will be shown and so on.
This works for simple questions. However the last question requires a more complex layout. Here 'Please add items' needs to have two inputs and an add button. Once pressed a table will appear with each row displaying the values passed into the fields from above. At the moment I can't do this as I am looping though a sub set of questions.
There could be 1000+ questions eventually and I am not sure whether creating a component for each question is the right approach?
I know my current approach isn't right some how but I am completely stuck how to approach this. Is there a way of looping through data and providing unique layouts for each question? The data structure isn't set in stone so feel free to change it.
https://codesandbox.io/embed/blazing-wood-ifnxym?fontsize=14&hidenavigation=1&theme=dark
Within the v-for, you can wrap the elements in a <template>, and then just use v-if to determine which element is displayed.
For example :
<template v-for="question in question.questions" :key="question.id">
<Input v-if="quetion.type === 'text'" :question="question" />
<Radio v-if="quetion.type === 'choice'" :question="question" />
...
</template>

Vuejs - How to change the text inside {{ }}

I've been building a data table recently and stuck at somewhere. I want my columns to be clickable to be able to display the rows in ascending and descending orders. When they are being displayed in ascending orders I want to show my arrow_upward icon and otherwise I want to show arrow_downward icon. Here is what I have done so far...
data () {
return {
arrow_upward: 'arrow_upward',
arrow_downward: 'arrow_downward',
}
}
and by the way, here is my usage of my Material Icons...
<span class="table-icons">arrow_upward</span>
I tried this one first;
<span class="table-icons" v-if="col == sortColumn">{{arrow_upward}}</span>
Basically I say, if it's sorted by column, show the arrow_upward icon. And here is my problem. How am I going to change inside the {{ }} everytime the column is clicked. It should work like a toggle and the interpolation tags should change between arrow_upward and arrow_downward. How do I do that?
You could use the following conditional rendering :
<span class="table-icons" >{{col == sortColumn?'arrow_upward':'arrow_downward'}}</span>
and no need to define them as data properties.

Programmatically return Partial View with correct index

I have a view that is rendering Person objects in a list called People in a table with dynamic rows. I render it like so in the HTML:
<partial name="_People" for="Model.People[i]" />
With i being the index in the for loop.
So it then goes and renders a partial view with the correct input names so I can bind back to it. Like so:
<input name="People[0].Name" ...
<input name="People[0].PhoneNumber" ...
I want to call back to my razor model to render a new row programmatically and have it return a row with the correct index. So say there are already 7 rows in the table, I hit a button and it returns a Partial View with my row inputs with the correct index of 8 in their names. I can then append this row to the table with javascript. So just wondering if there is a programmatic equivalent to
<partial name="_People" for="Model.People[8]" />
I figured it out. You can set the HTML Field Prefix in the view data template info.
Like so:
int index = 8;
ViewData.TemplateInfo.HtmlFieldPrefix = string.format("People[{0}], index)";

Selenium - Search for an element within element

Hi I want to hold element references in files somewhere. and then in run time search for elements withing referenced elements in Selenium how to do that.
For example- a Frame contains multiple text boxes -and multiple frames of similar properties exist where the textboxes are also duplicate. Something like I wanna reference the text box under a particular frame. But i wanna predefine the frame. and the specify that search under that frame[Something like Aliases in Testcomplete]
For Example - similar concept exist in Cheezy's Page-Objects. but not quite.
if you have a structure like this:
<div class='some class'>
<input class='input-button' value='submit'>Submit</input>
</div>
<div class='some class2'>
<input class='input-button' value='submit'>Submit</input>
</div>
and you want to find the first 'Submit' which is within the 'some class' div, you can do this:
parent_element = driver.find_element(:xpath, "//div[#class='some class']")
child_element = parent_element.find_element(:xpath, ".//input")
p.s. this is ruby code.