How to get dynamic data into textbox in flex? - apache-flex

Actually in my Flex Application i'm getting values from Database and Stored into a ArrayCollection...
[Bindable]public var data : ArrayCollection;
....
....
Actually ArrayCollection data contain values like...java,flex,dotnet,php.....
So now i'm adding this ArrayCollection into textbox for getting Dynamic value just like Auto-Suggestion
but it is giving all data once but i want when we type 'J' dynamically 'J' related words will be display....
Please help me....

The type of component you're looking for is called AutoComplete. There are quite a few implementations out there, but my favorite is the Flextras AutoCompleteComboBox, because I built it. It is available free for production use; but you'll have to register to download the SWC.

Related

Unable to Bind warning: class is not an IEventDispatcher

I found another similar question, but don't quite follow the explanation there, and not sure if it applies the same to me.
I am getting the error:
warning: unable to bind to property 'Description' on class 'Object' (class is not an IEventDispatcher)
this is only when the data is bound to a List as an ArrayList, though. I had it in a Datagrid before (just as an Array) and it did not cause any issue. I'm not expecting to be able to bind any data back to the class 'object' not even sure which object exactly it's referring to.
My list data-provider is an ArrayList.. populated by a result event from an SQL query contained in another class:
private function loadDayComplete():void
{
var Meals:Array = _day.MealResults;
var MealsListResult:ArrayList = new ArrayList(Meals);
MealPanelDataGrid.dataProvider = Meals;
MealListView.dataProvider = MealsListResult;
{
The day class I have is a data holder to get all the data (from several tables) for a 24 hour span.. I have classes for each individual datatype for editing them.
But I'm not sure do I even need to worry about the warning if I don't plan on editing the values? it completely spams the console though whenever I touch anything, so I really would like to get rid of it.
I tried an object proxy as I saw described elsewhere but nothing changed. And I'm pretty confused why it's suddenly an issue on a list component when it wasn't on a datagrid... The text is in label fields right now anyway, which can't even be edited.
The objects causing this warning are probably items inside Meals array.
Make sure that these items are strongly typed (Data Transfer Objects / Value Objects patterns) and that Description field is marked [Bindable].
Depending on the remoting mechanism you are using you may be able to use something like makeObjectsBindable flag which replaces returned Object items with bindable ObjectProxy instances.
But I'll advise strong typing anyway.
You can get rid of it by making your dataProvider an EventDispatcher: ObjectProxy is an EventDispatcher. It will automatically wrap your data to a specified or infinite depth (default behavior).
metaPanelDataGrid.dataProvider = new ObjectProxy(meals);
It's basically the same thing as with ArrayCollection but deeper.

flex/AIR datagrid access particular row

I am stuck in a problem working on Flex datagrid, in an AIR application.
How can I access a specific row in datagrid in Flex. Please note that i am not talking about the selectedItem or any particular record of dataProvider of datagrid.
What exactly I want to do is I am showing some files data (name, description etc.) on a datagrid, and the data of these files comes from an array which is the dataProvider of the datagrid.
Now when these files are being uploaded one by one to the server (using a webservice), I want to show a ProgressBar on, say, "Progress" column in the datagrid. How can I access this column for a particular row in datagrid i.e. current file being uploaded.
Please refer to image to better understand my query.
Please guide me.
Thanks
Preface, I use the Swiz Framework, so you will just have to adapt what I am saying to Native Flex or another framewok.
I would attack this by having an event that would be fired when you started the upload. This event would have a property that signified which filename is being uploaded.
var e:DataGridEvent = new DataGridEvent(DataGridEvent.START_FILE_UPLOAD);
e.fileName = uploadFileName;
dispatcher.dispatch(e);
Each row in the DataGrid is a new instance of an itemRenderer(there are no other ways to make it have a progressbar or anything fancy). So after setting the itemRenderer to your MXML component, just have it monitor the event being dispatched.
[EventHandler(event="DataGridEvent.START_FILE_UPLOAD", properties="fileName")]
public function startFileUpload(fileName:String):void
{
if(fileName == dataGride.fileName)
........//Show progress bar or whatever
In this manor, all of the rows will respond to the given event, and show the progress bar ONLY if it has the same filename as the file being uploaded. If filename isn't unique(I think it would be), you will have to have some sort of unique ID.
The same general process will be done with the status progress. Just fire a different event being FILE_UPLOAD_STATUS_UPDATE with the percentage and filename. Then handle the event properly.
The simplest way to meet your needs is to create custom item renderer with progress bar for progress column and add 3 additional fields to the file data (an element of your data provider):
public var inProgress:Boolean
public var bytesLoaded:int
public var bytesTotal:int
The progress bar in the item renderer can use data binding for switching visibility depending on inProgress flag value. And you can update progress using the same data binding with bytesLoaded and bytesTotal values.
You can read more about custom item renderers in official documentation.

Populate comboboxes INSIDE a datagrid with UNIQUE data IN actionscript (flex)

i've searched for several hours, and didn't find an answer for my problem.
i'm trying to place comboboxes in a datagrid filled with DYNAMIC data. (the number and the content of these comboboxes always change. i don't know in advance how many columns there are, where i need to use comboboxes. so every single combobox gets a unique dataprovider, which comes from an external source, WHEN the program runs.)
-i found MANY threads discussing this problem, but solving via crappy mxml files, filling the comboboxes inside the sourcecode by hand. i want to point out, that isn't good for me.
-i found a better solution, in which they used some sort of custom itemrenderer to get the data from the internet. (kind of a country chooser thing) but sadly that wasn't good enough, because the number and name of the countries in the world are static more or less, they don't change. so their renderer class didn't depend on any parameters from the main algorithm.
but in my program i calculate the data in my own actionscript objects, then fill an arraylist with that. so at the beginning i load the desired data from the net, and when i get the response of the urlrequest, AFTER that i start to populate the datagrid/combobox.
i can fill any datagrid or combobox without trouble, but to put that combobox inside a datagrid cell seems to be impossible.
could anyone please help? it drives me crazy. i managed to do this in several languages before, c#, java, even php+html, but in flex it looks way too complicated then it should be.
EDIT:
i'm aware, that this amount of network activity could mean some load on the server. i didn't design the philosophy behind it, i just need to wrote a client which meets the expectations. my program looks something like this:
(i'm willing to rewrite any part of it, just to make those nasty comboboxes work)
=========
main.mxml file
this is the main program, i handle some login related stuff here, and set basic design properties for the datagrids. (for example: maxwidth, maxheight, layout constraints etc.)
nothing interesting, except the command when i instantiate the actionscript class, which i wrote to fill the datagrid.
"..<fx:Script>
<![CDATA[
private var myGrid1:MyGridType;
..
somefunction {
myGrid1 = new MyGridType(theDatagridDefinedBefore, "argumentNeededToFillDataGridsWithUniqueData");
}
]]>
</fx:Script>.."
=========
MyGridType.as file
in the constructor i call a urlrequest with the help of the second argument, then add an eventlistener to it. when the data arrives, the eventlistener fires the filler function: i read the results into an arraycollection, then make it the dataprovider for the the datagrid in the first argument.
so far so good.
here comes the trouble with the comboboxes. for a specific number columns, i instantiate my combobox class. let's call that class "MyComboBoxType".
"..
blablabla = new MyComboBoxType(theDatagridDefinedBefore, param1, param2, param3);"
=========
MyComboBoxType.as file
i do nearly exactly the same, what i did in the MyGridType class. call for help from the net with param1-2-3. when i receive the data, fill an arraycollection. maybe set that arraycollection to be the dataprovider for a combobox. AAAAAAAND now i want that arraycollection or combobox to be on the datagrid "theDatagridDefinedBefore".
I know it's not exactly what you're trying to accomplish, but I had a somewhat similar issue in the past. Take a look at How to get the value of a ComboBox within a DataGrid to see if it helps.
If it were me, I would populate the entire ArrayCollection set before binding them to the datagrid if at all possible.
You should build up your custom [Bindable] data structure - say MyGridData class - for the rows in the grid (if you haven't done it yet);
the dataProvider of your grid should
be an Array / ArrayCollection /..
of MyGridData objects.
this step clearly works already, but
for the integrity: override the
getItemEditor function, or specify
it explicitly using mxml, to return
the combobox when needed.
as for the dataProvider of the
combobox, you should specify the
data.comboArray from inside the
renderer class, where data is the
MyGridData instance used by the row
you are processing. (overriding the
set data(value: Object):void
function, you can pre-process it.)
this way, you are working with the
reference of your original instances,
and by the binding you can detect /
show any changes to them directly.

Writing changes from editable datagrid back to local data store - Adobe Air/Flex

I am using Adobe Air to get data from SalesForce, and present it in a datagrid.
I am using a query to get the data, and then put it into an arraycollection that is bound to the datagrid, this works correctly and the data is displayed.
I have made the datagrid editable, and I am able to change the values in the datagrid, but I cannot find how to save the changes to the local database.
I am using the following code:-
protected function VisitReportGrid_changeHandler(event:ListEvent):void{
app.wrapper.save(VisitReportGridProvider)
}
But this has the following error when I try and compile it:-
1067: Implicit coercion of a value of type mx.collections:ArrayCollection to an unrelated type mx.data:IManaged.
Obviously I am doing this wrong, but I cannot find the correct syntax.
Thanks in advance for your help
Roy
This code is not enough to understand where actually is the problem
Need to know what is VisitReportGridProvider, what is wrapper.save() method.
**after comment:
F3DesktopWrapper.save():
public function save(item:IManaged):void
Saves the specified Managed object to the local database. You must make an explicit call to syncWithServer() to update the data on the salesforce server. However, do not call syncWithServer() too often (batch your save calls) as this may use up your alloted API usage. If the item is in conflict, the conflict will be resolved.
Parameters:
item:IManaged — The managed object to create or update.
you're passing parameter with type ArrayCollection which doesn't implement IManaged interface.
You need to pass the item in the ArrayCollection that was changed to the save function. Like:
acc.fieldCollection.updateObject(new AsyncResponder(function(o:Object, t:Object):void {
app.wrapper.save(o as Account);
}, function(e:Object):void {
}));

XtraGrid doesn't display properly newly added line

I'm using XtraGrid of DevExpress 2.9.5 to display a blotter of dynamic set of lines. The blotter is integrated into another application, this is why it has to be based on UserControl class and also implement a couple of custom interfaces.
public partial class BlotterForm : UserControl, ISMMdiEmbeddable, ISMAssociatedMFCWindow
{
private BindingList<BlotterTrade> fDeals;
....
}
As the data is binded to control using BindedList, any change should be reflected in the form automatically. And if I try to add new line to fDeals like follows:
public void AddDeal()
{
fDeals.Add(new BlotterTrade(1,2,3));
}
... i can see the line, but it's content is rubbish.
I tried to do the same in a small test application. It works ok with only difference that the blotter in test application is based on DevExpress.XtraEditors.XtraForm. To me it looks now that the form of original blotter doesn't overload some method or miss some event. But I cannot find out what exactly is missed.
Can somebody tell me what I do wrong or don't do?
Thanks.
A couple of things:
BindingList doesn't always work too well with DevExpress, and it's suggested to use XPCollection instead.
Do you have any more info about how you setup your columns in the xtragrid? If you use incorrect field names in the column, then they won't show what you're looking for.
If the params you're using (1, 2, 3) are ids stored as fkeys to other objects (not sure if you're using xpo or not) then they won't show up correctly either (there'll likely be a '+' in the cell instead of any values).
[aside] be sure that blottertrade implements INotifyPropertyChanged for better interaction with the grid.
Thanks to everybody for the answers and comments. I think I sorted out the problem. It was actually related to interaction between native C++ and C# layers in my application. The object that was supposed to be displayed in XtraGrid was created in C++ layer, the grid was displayed asynchronously with object construction/deconstruction, that's why at the moment when the grid was ready to display it, the object itself didn't exist. Hence the rubbish. It's good the grid itself was not crashing or firing exceptions.

Resources