Cannot access to the values in Struct in a table view cell. Read the described code in the screenshot below - tableview

enter image description hereScreenshot of error I am accessing the value from a structure in tableviewcell class , I wanted the value from the structure for making the api call .

Your error is
Can not subscript [Section] with index of type (item).type
is for this line
let item: Item = sectionData[item]
It explains that you cannot use item type value while subscripting on array.
You will need to pass some Index, i.e some Int value
Update your code with some proper index
let item: Item = sectionData[indexOfSectedRow]
Hope it helps.

Related

Populate a variable in controller with single row data from a query

I have in a Codeigniter 4 controller this code:
$competicion =$db->table('competiciones')
->select('*')
->where('competiciones.slug', $blog_slug)
->get()->getRowArray();
How can I get and save in a variable id_competicion value, for example? I try this code but it is wrong:
$competicionid = $competicion->[competicion_id];
getRowArray() returns an array, the correct approach to retrieve an array value would be:
$competicionid = $competicion['competicion_id'];
another possibility would be to use getRow(), which returns an object. To retrieve an object value you could use:
$competicionid = $competicion->competicion_id;
read more: Generating Query Results: Result Rows

How to show an array (multiple values) in a webix datatable column

I need to show multiple values (rank and vote) together separated by space as key:value in a webix datatable cell from the following structure :
id2: [{"rank":2, "vote":50}, {"rank":3, "vote":10}]
I want to show only the first element of this above array.
My snippet is here : https://webix.com/snippet/ca50874d
I am not able to figure out how to show these two values together in one cell.
Please help.
Thanks.
To show multiple values in the cell, or if you want to format the value according to you, you just need to use to template for that cell:
While specifying column configuration, you can specify the template for that particular column like below:
template:function(obj) {
}
This template will be called for each row, and obj contains the row object.
For your example you can specify the template like below:
template:function(obj) {
return obj.column1 +':' + obj.column2;
}
I further tried and could figure out the answer on my own. To show the first element of that array object, the 'map' attribute has to be used as below:
{ id:"id2", header:"Rank", width:80, map:"#id2[0].rank# : #id2[0].vote# "}
The working snippet for the same is here : https://webix.com/snippet/928bab77

How to get attribute value of mutiple selection in the Owebia shipping method

How to get attribute value of multiple selection in the Owebia shipping method?
My Owebia code below:
{count items where array_match_any(product.attribute.**shipping_restriction**.**value**', array('AU','NZ','AU,NZ'))}
But,I can't get the attribute value,I only can get the id num of attribute,
shipping_restriction is my custom attribute,which has a multiple selected menu.
It just return the index num,not 'NZ' or 'AU',it just return the index num,not 'NZ' or 'AU'
If I have changed the multiple selected menu into single selection,it could get right value. Like 'NZ' or 'AU',and not index num.
You can try by using following syntax to get value.
product.attribute.*.value
Where * is attribute placeholder.
Reference: http://www.owebia.com/os2/en/doc#formulas_variables_product

accessing array values in view

I have the following code in zend:
$arrErrors=array();
if (!empty($this->post['submit']))
{
// Each time theres an error, add an error message to the error array
// using the field name as the key.
if (empty($this->post['client_name']))
$arrErrors['client_name'] = "Please Enter Client's name as it appears in the carrier software";
}
if i set $this->view->arrErrors=$arrErrors in the controller,
Can I access it as $this->arrErrors['client_name'] in the view?
i aplogize for a silly question.
Here is right approach:
$this->view->arrErrors=arrErrors['client_name'];
Use the above code in the controller

Linq Object as ComboBox DataSource

I have a ComboBox being bind to LINQ object as below.
Dim LearnTypeList = context.LearnTypes.OrderBy(Function(a) a.LearnType).ToList()
dlLearnedAbout.DataSource = LearnTypeList
dlLearnedAbout.DisplayMember = "LearnType"
dlLearnedAbout.ValueMember = "LearnType"
I am not able to use Index of Items to find Item with matching text as below .
MessageBox.Show(dlLearnedAbout.Items.IndexOf("Website"))
This always returns -1 even if its there inside the table and dropdown.Is it because the Item bound to the Dropdown is of type "LearnTypes ?
IndexOf("Website") is looking through the list for an item of type String. your list doesn't contain strings though - it contains objects of whatever type you have in context.LearnTypes. that's why you are getting -1 (aka item not found)

Resources