on 09-24-2009 2:50 PM
Hi everybody,
I have quite a simple question, however, I do not really get a solution for that on my own.
Actually, all I want to do is extend a usual Datagrid to display my data from XCelsius using the standard propertysheet. The way I tried to do this was to make the dataProvider inspectable.
My actionscript file:
package myPackage
{
import mx.controls.DataGrid;
[CxInspectableList("dataProvider")]
public class MyDG extends DataGrid
{
public function MyDG()
{
super();
}
[Inspectable(defaultValue="undefined", type="Array2D")]
[ArrayElementType("Number")]
override public function get dataProvider():Object
{
return super.dataProvider;
}
override public function set dataProvider(value:Object):void
{
super.dataProvider(value);
}
}
}
When I pack this into an .xlx, I can view it and preview it as long as I do not try to change the dataProvider. When changing it, the preview window stops to load at some point.
Thanks for your help in advance!
The SDK only suppots passing in simple data types or a basic Array, the dataProvider is probably using an ArrayCollection which will not work.
Instead create your own property which takes an Array in (which internally passes the array to the dataProvider).
Regards
Matt
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Guys,
I need some help please, i got the 2D Array working by implementing a custom sheet and setting the type to "Array2D", thanks for the solution. Now I'm faced with a different dilemma, I now need to be able to detect what row in the Array has changed, my variable in Bindable as in the code below, and I'm firing a method in the GET method, and this works fine, but I need to send the array's row index for the row that was changed.
// messages Property - must be set to [Bindable] so that it can change dynamically
[Bindable]
[Inspectable(type="Array2D")]
public function get messages():Array
{
launch(); //method gets fired when Array is changed, at this point i need to know which row has changed
return _messages;
}
public function set messages(value:Array):void
{
if (_messages != value)
{
_messages = value;
_messagesChanged = true; // Changing the messages array.
invalidateProperties();
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello JSchneider,
Thanks for the reply.
Now i am passing it as of type ARRAY2D.
suppose if A B
3 P1 C1
4 P2 C2
Suppose A and B are the columns in an excel sheet.Here 3 and 4 are rows.
when i select $A3$B4 it takes as P1,C1 and P2,C2
Does Xcelsius internally take like this for ARRAY2D type?
suppose i want to pass the above as a 2D array consisting of two elements one is P1,C1 and the other is P2,C2
how can i do that?
Appreciate your help in advance...
Thanks,
Sreelekha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sreelekha,
This is how Flex creates 2d arrays so Xcelsius does the same when it passes a 2d array.
var cells:Array =
[
/* row 1 */ [ column 1, column 2, column 3],
/* row 2 */ [ column 1, column 2, column 3],
/* row 3 */ [ column 1, column 2, column 3]
];
So in your case:
var cells:Array =
[
[P1, C1],
[P2, C2]
];
So cells.length tells you how many rows are in the 2d array.
And cells[0].length tells you how many columns are in the first row of the array (assuming there is at least one row).
So as in Flex if you want to process a Flex 2d array you do something like this:
for (var i:int = 0; i < cells.length; i++)
{
var row:Array = cells<i> as Array;
for (var j:int = 0; j < row.length; j++)
{
var rowColCell:* = row[j];
// rowColCell has the value for this row/column cell.
}
}
Regards
Matt
Thanks Matt,your answer is a good one.
Sending of data to my component from excel is working fine now,but i have one more issue regarding passing of selectedItems from list to my excel.
its just displaying [Object Object] if i select any items.
do i need to modify the selectedItems getter method.i am completely lost here.
Could you please suggest me on this ??
Thanks,
Sreelekha.
The SDK only suppots passing in simple data types or a basic Array, the dataProvider is probably using an ArrayCollection which will not work.
Instead create your own property which takes an Array in (which internally passes the array to the dataProvider).
Regards
Matt
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi All
This is Sreelekha.I am trying to make a custom tree component.I am facing a problem in binding the tree's data provider to the excel cell.I am using ArrayCollection as dataProvider to the Tree.
Its giving me the below error:
TypeError: Error #1034: Type Coercion failed: cannot convert mx.collections::ArrayCollection@3507af81 to Array.
at MethodInfo-2997()
at xcelsius.binding::XCChangeWatcher$/bindProperty()
at xcelsius.managers::SpreadsheetBindingManager/createInputBinding()
at xcelsius.managers::SpreadsheetBindingManager/bind()
at xcelsius.spreadsheet::Document/bind()
at template3060890695-50239-4574-128-41-1718711110910977/createUIComponents()
at template3060890695-50239-4574-128-41-1718711110910977/initComponents()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at mx.core::UIComponent/callLaterDispatcher2()
at mx.core::UIComponent/callLaterDispatcher()
Can anyone help me in this regard?
Appreciate your help...
Thanks,
Sreelekha
Hi Sree Lekha,
you'll have to make a kind of "placeholder" property of type array in your Component, which is used for data binding with XCelsius, that simply passes its values to the dataprovider in its set and get method. You might need to slightly convert the data coming from XCelsius into something your component understands.
Edited by: JSchneider on Oct 29, 2009 10:42 AM
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.