I have this code as a change function on a DropDownList in Flash Builder:
public function chooseCategoryDDL_changeHandler(event:IndexChangeEvent):void {
var para:Object = new Object();
para.action = "changecategoryxml";
para.book_class = event.selectedItem.book_class;
if (event.selectedItem > -1 ) {
changeCategory.send(para);
}
However I get a code hint stating that there's 'access of undefined property selectedItem'. Yet when I set the para.book_class to be:
para.book_class = event.IndexChangeEvent.book_class;
The code hinting then states error '1078: Label must be simple identifier'. What i'm trying to do is when a user clicks on a selected item from the DDL, the 'changecategoryxml' function is called if the selected item is > -1 (as the DDL is an ArrayCollection). Please can anyone help me with the correct syntax?
Any help is greatly appreciated. Thank you.
EDIT: I now know how accept rates works, please don't be put off by the relatively low percentage!
I always use event.currentTarget.selectedItem with the IndexChangeEvent. That should work in your case as well.
Related
How to show current rows in ag grid.
I am using below code which gets executed when onFilterModified is called.
let tempRowCount = this.api.getModel().getRowCount();
console.log("temp count changin",tempRowCount);
// alert("row count"+tempRowCount);
this.noOfRowsVisible = String(tempRowCount);
Then I am binding the variable noOfRowsVisible to view(HTML).
The problem is I am able to get filtered rowcount in console as defined above in the method. But view is not updated with new value of noOfRowsVisible.
Please help someone.
Thanks in advance.
I have a dropdown menu in d3.js, and I would like to get the index from the selected option. It's a list of a bit more than 50 flight companies, and right now I have this :
function choixCompagnie(){
let compagnieChoisie = d3.select(this).property('value')
}
This function activates whenever there is a change on the drop down, like so :
d3.select("#selectCompagnie")
.on("change",choixCompagnie)
The property('value') means that for instance if I click the first line of my drop down menu, which is Aer Lingus, my compagnieChoisie variable will get the value Aer Lingus instead of 0.
I need it because I then need to access some properties company by company, and my objects are in an array. So in my database I need to access the properties like this data[index].randomProperty and not like this data["Company Name"].randomProperty, since the company name is already a property.
I don't know if this makes sense, sorry if I'm using the wrong terms I'm fairly new to coding.
Thanks for the help !
edit : here is a working example http://blockbuilder.org/ArnaudStephanUNIL/a18332a561579eb929091faaff91fb6f, where the drop down gets the value but not the index
You should access your data like this:
function choixCompagnie(){
let compagnieChoisie = d3.select(this).property('value')
console.log(data.find(d => d.compagnie === compagnieChoisie).accidents);
}
I found a better, easier way to get the index from a drop down menu :
<select id="selectOptions"></select>
Once you initialized your drop down menu, you simply have to do this :
var options = ["option1","option2"];
options.forEach(function(d,i){
d3.select("#selectOptions")
.append("option")
.attr("value",i)
.text(d);
})
Would appreciate you help for the following.
I have created a reminder but I want to update it before or after the reminder nofiticaton has activated. here the code.
Problem : it wont work even if there is no compilation error for this code.
var Myreminders = ScheduledActionService.GetActions()
.Where(a => a.BeginTime.Month == month);
foreach (Reminder r in Myreminders)
{
string strMyRmd;
strMyRmd = r.Name.ToString();
if ( strMyRmd == "MyName1" )
{
r.Title = "Today Shopping";
}
}
Thanks
I believe (I can't test this from my computer but have confirmed this works with Background Agents) that you need to find your Reminder, remove it from the scheduled action service, update and re add it.
var reminder = (Reminder)ScheduledsActionService.Find("MyReminder");
ScheduledActionService.Remove("MyReminder");
reminder.Title = "Updated Title";
ScheduledActionService.Add(reminder);
According to the remarks section in ScheduledActionService.GetActions Method documentation page:
The Scheduled Action Service does not maintain a reference to the
objects returned by this method, and therefore the properties of the
objects are not updated to reflect the current state after the call to
GetActions. To obtain an object that is updated by the system as its
state changes, use Find(String) instead.
So, just use Find(String) instead.
Hi I been searching for my error but I can't find anything that help me. The problem is this. I been working with Subsonic 3, Newtonsoft Json and the linq way of write so I have this easy query:
var found = from client in newclients.All() where client.Period == "sometext" select client;
string periodoJSON = JsonConvert.SerializeObject(periodoFound); //this get "Self referencing loop Exception"
the problem is when I run this script I get the horrible exception "Self referening loop exception" in the JsonConvert line, subsonic have all the objects without any problem but if I do the following.
var found = from client in newclients.All() where client.Period == "sometext" select new client{client.Name, client.LastName, etc};
string periodoJSON = JsonConvert.SerializeObject(periodoFound);
I get the object serialize with a any problem with all the properties. I'm doing the last way because I have to finish my work but is any other way or solution for this problem, if not I will have to write all the properties every time I want to get a full table properties.
hope any can solve my problem o help me in the path for find a solution....
what I have is a really basic query with linq and I try the three values for JsonSerializerSettings and any work, again I'm working with subsonic 3 this not happend either with subsnoic 2 and I can make it work if I specify one by one the properties of the object in the linq query does any have any clue of what is happend, ANY more help would be great!!! If I put the value of Serialize my page get crazy and in a infinity loop state, if I decide for error simple doesn't work and Ignore nothing happen... some more information about this self referencia loop?
var u = usuario.SingleOrDefault(x => x.TipoUsuario == "A" || x.TipoUsuario == "W");
JsonSerializerSettings setting = new JsonSerializerSettings();
setting.ReferenceLoopHandling = ReferenceLoopHandling.Error; //.Serialize .Ignore
Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"usuario", "var usuario=" + JsonConvert.SerializeObject(u, Formatting.None, setting) + ";");
Update ------
I code the following
string jsU = JsonConvert.SerializeObject(u,Formatting.None,new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.Objects, ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
and is workign but the only thing wrongs is that in the json object comes all the information about the columns of subsonic 3 and a BIG chunk of text explain it... does any one know how to not SEND this part of the object??
Without knowing more about you object model it is hard to provide a definitive answer, but I would take a look at the ReferenceLoopHandling enum.
You're calling string SerializeObject(object value) on JsonConvert. Try the string SerializeObject(object value, Formatting formatting, JsonSerializerSettings settings) method instead. The JsonSerializerSettings settings parameter lets you set a bunch of things, including the ReferenceLoopHandling ReferenceLoopHandling { get; set; } property.
You can try these values:
public enum ReferenceLoopHandling
{
Error,
Ignore,
Serialize
}
Obviously, Error is the default and that's what you're getting. Perhaps one of the others will help.
I have a ‘featured’ attribute, which has a Yes/No select-list as the admin input. I presume that the values for Yes and No are 1 and 0, as they are for every other Yes/No list. However, if I try and filter a collection using the ‘featured’ attribute, it doesn’t work:
$feat_attribute = $_product->getResource()->getAttribute($featuredattribute)->getSource()->getOptionId(1);
But, if I make a ‘featured’ attribute with a dropdown, and write my own Yes and No, then it works as below:
$feat_attribute = $_product->getResource()->getAttribute($featuredattribute)->getSource()->getOptionId('Yes');
Anyone any ideas? I’ve also tried values as true/false, yes/no, on/off etc, but no joy.
This seems to be an old thread, but anyway I just had the same issue, I set the attribute to be visible in product listing and product view, and then apply addAttributeToFilter(feature_product_attribute, 1) for Yes/No type.
Maybe you are supposed to use '1' and '0' instead of the integer-values?
Like:
$feat_attribute = $_product->getResource()->getAttribute($featuredattribute)->getSource()->getOptionId('1');
Whenever Magento's behavior is confusing me, I start hacking on the core source (a development copy, of course) to see what it's doing and why not doing what I think it should. I haven't done much playing around with the Admin UI stuff so I don't 100% understand your question, but take a look at the getOption function
File: /app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Abstract.php
public function getOptionId($value)
{
foreach ($this->getAllOptions() as $option) {
if (strcasecmp($option['label'], $value)==0 || $option['value'] == $value) {
return $option['value'];
}
}
return null;
}
I'd add some Mage::Log and/or var_dump calls in there for the values of $option['label'] and $option['value'] and see why your comparison is failing.