I have a list of records that returns in the following format
Record(emailAddress=1234#gmail.com,Id=12313,optChoice=OUT, lastUpdateDate=2022-03-03T08:24:40.469898Z)
Record(emailAddress=56789#gmail.com,Id=12313,optChoice=in, lastUpdateDate=2022-04-03T08:24:40.469898Z)
I want to return my opt choice and everything else can be ignored. Any tips on how to do that?
You can use the map function. For example: list.map { it.optChoice } (where list is the name of your list variable) which will return you a list of the optChoice values. See for more info: https://kotlinlang.org/docs/collection-transformations.html#map
Related
I am getting below sample data from api dynamically.
Can anyone suggest how to apply condition based on data.
You need to check values in array
if (this.tagSchemaDetails.schema_context.providers.indexOf('All') < 0) {
request['schema_context'] = this.createConditionsData();
}
As your providers is array of string and you are just comparing that with string so in all cases it will validate the condition.
So you have to check the strings in the array and compare them with 'All' to properly check the condition.
So your code should look like this:
if(!this.tabSchemaDetails.schema_context.providers.includes('All')){
request['schema_context']=this.createConditionsData();
}
as others have said here, you have to check values in the "providers" array. since you just need to check provider != 'All' you can simply check for the first element in the array as below.
if (this.tagSchemaDetails.schema_context.providers[0] !== 'All') {
request['schema_context'] = this.createConditionsData();
}
How can ı equalize my array ıd and my value ıd and access value.name I didn't do it
This is my code:
activity(val) {
var act = this.items.map(function (val) {
if (element.ActivityID== val) {
return element.ActivityName
}
return act
});
Perhaps this?
activity (val) {
const activity = this.items.find(item => item.ActivityID === val)
return activity && activity.ActivityName
}
This just finds the item with the corresponding ActivityID and then returns its ActivityName.
Your original code contained several possible mistakes:
Two different things called val.
element doesn't appear to be defined.
The return act was inside the map callback. The activity method itself wasn't returning anything.
Not really clear why you were using map to find a single item. map is used to create a new array with the same length as the original array with each item in the new array determined by the equivalent item in the original array. It 'maps' the items of the input array to the items in the output array.
I am trying to group my store on department name . Department name contains some null values also . when i am trying grouping along with sort function its result in multiple group from same name.
see this fiddel for details. I am not getting what i am doing wrong. Kindly advise.
Your sorterFn is wrong.
The sorterFn has to return three different values:
1 if the second argument is strictly greater than the first.
-1 if the second argument is strictly smaller than the first.
0 if both arguments are the same group.
Your sorterFn never returns 0. Try this one:
sorterFn: function(a, b) {
if(a.get('department')=="Management" && b.get('department')=="Management") return 0;
if(a.get('department')=="Management") return 1;
if(b.get('department')=="Management") return -1;
if(a.get('department') < b.get('department')) return 1;
if(a.get('department') > b.get('department')) return -1;
return 0;
},
Furthermore, your transform function is useless. It is called only from the original sorterFn, which you overwrite. You would have to account for null values in your sorterFn, if you wish so. (However, usually one would put fallback categories like "Others" in the end, not between "IT" and "Sales".)
Also, to write the department in the header line, you have to override the groupHeaderTpl template, e.g.
groupHeaderTpl: [
'<tpl if=\'name\'>{name}<tpl else>Others</tpl>'
]
I have a list stored in database as varchar. When I read the list value, it is read as string. I'm trying to convert string to a valid list
Here are 2 example lists I have
str_db_bins = [10,20,30,40] (This is string)
The desired output is
str_db_bins_list = [10,20,30,40] (This is list)
I want to convert this to list. When I use split method I get [[,1,0...]] which is not the desired output
2nd situtation is
str_db_lov = ['id','num','val'].
When I use split method, again I get weird output
The desired output is to read this as list
str_db_lov_list = ['id', 'num', 'val']
How do I deal with these situations
Thanks
Pari
str_db_bins_list = eval(str_db_bins)
str_db_lov_list = eval(str_db_lov)
I have an array, lets call it _persons.
I am populating this array with Value Objects, lets call this object PersonVO
Each PersonVO has a name and a score property.
What I am trying to do is search the array &
//PSEUDO CODE
1 Find any VO's with same name (there should only be at most 2)
2 Do a comparison of the score propertys
3 Keep ONLY the VO with the higher score, and delete remove the other from the _persons array.
I'm having trouble with the code implementation. Any AS3 wizards able to help?
You'd better use a Dictionary for this task, since you have a designated unique property to query. A dictionary approach is viable in case you only have one key property, in your case name, and you need to have only one object to have this property at any given time. An example:
var highscores:Dictionary;
// load it somehow
function addHighscore(name:String,score:Number):Boolean {
// returns true if this score is bigger than what was stored, aka personal best
var prevScore:Number=highscores[name];
if (isNaN(prevScore) || (prevScore<score)) {
// either no score, or less score - write a new value
highscores[name]=score;
return true;
}
// else don't write, the new score is less than what's stored
return false;
}
The dictionary in this example uses passed strings as name property, that is the "primary key" here, thus all records should have unique name part, passed into the function. The score is the value part of stored record. You can store more than one property in the dictionary as value, you'll need to wrap then into an Object in this case.
you want to loop though the array and check if there are any two people with the same name.
I have another solution that may help, if not please do say.
childrenOnStage = this.numChildren;
var aPerson:array = new array;
for (var c:int = 0; c < childrenOnStage; c++)
{
if (getChildAt(c).name == "person1")
{
aPerson:array =(getChildAt(c);
}
}
Then trace the array,