Two comboBox in a datagrid
Hi All,
When I create a new line in my grid I want to include two
comboBox, the
second comboBox related to the first one.
I got it work partial, I can create the second combo on the
fly but how can
I insert the combo into the grid for specific row and column.
The column is the same but the row change if I add one.
Thanks
JFB
Yes? but how in a dynamic form?
This is what I'm doing... my setCategory function fill the
array for the
second comboBox but this only work for one row in my datagrid
because if I
set the second row in my datagrid and I change the option in
my first
comboBox it change the values for all second comboBox values.
Now I can create a new comboBox on the fly but if I say
comboBox.id =
"materialItem_cb" it doesn show in the datagrid.
How can I do this? Please help... I'm trying different things
without luck
Tks
JFB
public function setCategory(tempCombo:ComboBox):void{
acMaterialsItem.removeAll();
for each (var item:Object in acAllItems) {
if (item.itemCategoryID == tempCombo.selectedItem.id) {
acMaterialsItem.addItem(item);
<mx:DataGridColumn headerText="Category"
dataField="itemCategoryID"
editable="false" width="150">
<mx:itemRenderer>
<mx:Component>
<mx:VBox>
<mx:ComboBox id="category_cb"
dataProvider="{outerDocument.acItemCategory}"
labelField="label"
change="outerDocument.setCategory(category_cb)"
width="150"/>
</mx:VBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn headerText="Material Description"
dataField="materialItemID" editable="false" width="200">
<mx:itemRenderer>
<mx:Component>
<mx:VBox>
<mx:ComboBox id="materialItem_cb"
dataProvider="{outerDocument.acMaterialsItem}"
labelField="label"
width="200"/>
</mx:VBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
"ntsiii" <[email protected]> wrote in message
news:f98ags$h40$[email protected]..
> This must be handled by your item renderer.
>
> Tracy
Similar Messages
-
Grid filtering with textInput and TWO comboboxes...
I am trying to combine some code based on Ben Forta's example
and another I found on cflex.net. The idea is to have a text
"as-you-type" search on a Grid, and also be filtered by not one,
but two comboboxes, each pertaining to different columns of the
grid. The code below works, but it is only 1 combobox and a
textInput. How can I add the second combobox?
Each piece of code works find on its own, but I'm just having
trouble putting them all together. The second combobox's code is in
block comment below.
The rest of the application is like this: the grid is
dgObjectList with dataProvider objectList. (ArrayCollection) It has
objName, typeName, and courseName for columns. It is filtered via
an inputText (for objName), and two comboBoxes cbTypeList and
cbCourseList (for typeName and courseName). All three have
change="objectList.refresh();"
The resultHandler for the grid's data has:
objectList.filterFunction=processFilter;
And finally, here's the filter I have so far...any thoughts
on getting the second combobox in there? The problem is once an if
statement passes, the rest of the function doesn't run.
quote:
private function processFilter(item:Object):Boolean {
var result:Boolean=false;
dgObjectList.selectedIndex = -1;
checkForDisplay();
if(item.objName.length == 0 ||
item.objName.toUpperCase().indexOf(searchText.text.toUpperCase())
>= 0) {
if(cbTypeList.selectedItem.typeName != "Show All") {
return item.typeName == cbTypeList.selectedItem.typeName;
} else if(cbTypeList.selectedItem.typeName == "Show All") {
return true;
/* Second ComboBox:
if(cbCourseList.selectedItem.courseName != "Show All") {
return item.courseName ==
cbCourseListselectedItem.courseName;
} else if(cbCourseList.selectedItem.courseName == "Show
All") {
return true;
return result;Here is a complete working example.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute"
creationComplete="creationCompleteHandler(event);">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.FlexEvent
[Bindable]
public var theRegion: Array = [ {label:"State",
data:1},{label:"North", data:"N"}, {label:"South", data:"S"} ];
[Bindable]
public var newPremise: Array = [ {label:"Premise",
data:1},{label:"On", data:"ON"}, {label:"Off", data:"OF"},
{label:"Military", data:"MI"} ];
private var tmp_objectList:Array =
{Premise: "On",Region: "North",objName: "Intro", typeName:
"ColdFusion", courseName :"Intro To ColdFusion"},
{Premise: "Off",Region: "South",objName: "Programming",
typeName: "Flex", courseName:"Flex Programming"},
{Premise: "Military",Region: "South",objName: "Development",
typeName: "Apollo", courseName:"Apollo Development"}
[Bindable]
private var ObjectList:ArrayCollection;
private function
creationCompleteHandler(event:FlexEvent):void
ObjectList = new ArrayCollection (tmp_objectList);
ObjectList.filterFunction=processObjectListFilter;
public function processObjectListFilter(item:Object):Boolean
var result:Boolean=false;
if (
(txtFilter.text == '' || (item.objName != null &&
String(item.objName).toUpperCase().indexOf(txtFilter.text.toUpperCase())
>= 0)) &&
(aRegion.selectedLabel == 'State' ||(item.Region != null
item.Region.toUpperCase().indexOf(aRegion.selectedLabel.toUpperCase())
>= 0)) &&
(premisefilter.selectedLabel == 'Premise' ||(item.Premise !=
null &&
item.Premise.toUpperCase().indexOf(premisefilter.selectedLabel.toUpperCase())
>= 0))
result=true;
return result;
]]>
</mx:Script>
<mx:ComboBox id="aRegion" dataProvider="{theRegion}"
width="70" change="ObjectList.refresh();"/>
<mx:ComboBox id="premisefilter"
dataProvider="{newPremise}" width="85"
change="ObjectList.refresh();" x="78"/>
<mx:TextInput x="34" y="249" id="txtFilter"
change="ObjectList.refresh();"/>
<mx:DataGrid dataProvider="{ObjectList}" x="34" y="279"
width="596">
<mx:columns>
<mx:DataGridColumn headerText="Region"
dataField="Region"/>
<mx:DataGridColumn headerText="Premise"
dataField="Premise"/>
<mx:DataGridColumn headerText="objName"
dataField="objName"/>
<mx:DataGridColumn headerText="typeName"
dataField="typeName"/>
<mx:DataGridColumn headerText="courseName"
dataField="courseName"/>
</mx:columns>
</mx:DataGrid>
<mx:Text x="34" y="223" text="Type As You Go Filters
objName" color="#ffffff"/>
</mx:Application> -
Dynamic comboBox in a dataGrid?
i have a dataGrid that starts out blank. When a button is
clicked, it populates based on the contents of a few components.
The 3rd column needs a comboBox. I need the following
behaviors:
1-when the button is clicked, this populates with the text
values in a certain text field.
2-under certain circumstances, i need to be able to add and
subtract from this comboBox.
i have read this:
http://blog.flexmonkeypatches.com/2008/02/18/simple-datagrid-combobox-as-item-editor-examp le/
but it looks like the comboBox in that example has fixed
values. How can i dynamically alter the values in
these comboBoxes? i have the comboBoxes in the dataGrid
component, but i can't figure out how to access their
dataProviders!
thanks!You can have your comboBox itemRenderer populate based on an
ArrayCollection in your dataDrid dataProvider. Then, by changing
the dataProvider's ArrayCollection field, you could change each of
the comboBoxes accordingly. If you need different comboBox values
for different comboBoxes, then you will need something a bit
different. It would help to see your code.
Vygo -
Hi all,
How can I put a comboBox inside a datagrid?
I want to set the comboBox with their own dataprovider and
the id should
pass to the datagrid fill at the save time.
I try this but doesnt let me to include a dataprovider.
Any links??
please help and thank you in advance.
JFB
<mx:DataGridColumn headerText="Rate" dataField="rate"
editable="false">
<mx:itemRenderer>
<mx:Component>
<mx:VBox>
<mx:ComboBox id="rate_cb"></mx:ComboBox>
</mx:VBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>Hi,
I think you need to declared your array public at the
begining of the page
like
[Bindable]
public var dataArray = new ArrayCollection();
You need to use outerDocument.
<mx:ComboBox activate="true" labelField="TEXT"
dataProvider="{outerDocument.dataArray}" />
I discover that the components are case sensitive also.
I hope this help.
JFB
"MLK_SS" <[email protected]> wrote in
message
news:[email protected]...
> Hi All,
>
> I am having a problem displaying data into a combo box
inside a data grid.
>
> I am getting data from a webservice and storing the data
into a Array
> Collection variable and trying to pass the var as the
data provider for
> the
> combo box.
>
> If I try an individual combo box it works fine.
>
> But, when trying to integrate into a datagrid it gives
an error saying
> Access
> of undefined property. I tried using outerDocument as
mentioned above, the
> error doesnot show up but the output does not show up
with the data inside
> the
> Data grid Combo box.
>
> <mx:DataGrid id="fav" x="10" y="332"
headerColors="[#C3D3AA, #C3D3AA]"
> enabled="true" editable="true"
textDecoration="underline">
> <mx:columns>
> <mx:DataGridColumn width="120" headerWordWrap="true"
> headerText="Fav./Del./ Copy/Edit" fontWeight="bold"
editable="false"
> dataTipField="Favourites" activate="true" >
> <mx:itemRenderer>
> <mx:Component>
> <mx:VBox>
> <mx:ComboBox activate="true" labelField="TEXT"
> dataProvider="{dataArray}" />
>
> </mx:VBox>
>
> </mx:Component>
> </mx:itemRenderer>
> </mx:DataGridColumn>
> </mx:columns>
> </mx:DataGrid>
>
> the function that handles the data result is :
>
> public function handleResult(event:ResultEvent):void{
>
> dataArray = new ArrayCollection();
>
> tasktypeArray = new ArrayCollection();
> var myXML:XML = new XML(event.result);
> var kf:XMLList = myXML.child("WORKLIST");
>
> var tasktype:XMLList = myXML.child("TASKTYPE");
> a = kf.item;
> b= kf.item[0].TEXT;
>
> textarea1.text = myXML.toXMLString();
> textarea3.text = myXML.child("TEMPLATE");
> trace(kf.child("TEXT").length());
> for (var x:int = 0; x < 25; x++) {
> var resultObj:Object = new Object ();
>
> resultObj.TEXT
> =tasktype.descendants("item")[x].TEXT.valueOf();
> dataArray.addItem(resultObj);
>
> }
>
> Please let me know where I am going wrong
>
> Thanks,
>
> -
Hi,
I want to embedded a ComboBox in a Datagrid.
The data displays in the Combox with the code in the
ComboBoxCellRenderer.as:
public function set data(value:Object):void {
_data = value;
var dp:DataProvider = new DataProvider(value.plaats);
dataProvider = dp;
public function get data():Object {
_data.plaats = arr;
return _data;
-How can I transmit the ComboBox.selectedItem to the Datagrid
-and how can I read the CellRenderer.data in the DataGrid,
var cr: ComboBoxCellRenderer =
Datagrid.itemToCellRenderer(e.item) as ComboBoxCellRenderer
=>returns null
trace(cr.data);
Thanks for helping meHi,
I'm sorry to bug you with a non-technical discussion, but I
am a recruiter in San Diego. My client is in need of 3 Senior Flex
Developers for their project. I have had an extremely rough time
finding someone for this position. Would you be interested in this
position, or do you know of anyone that might be? We do pay
referral fees. This position may be open to telecommuting.
Job Description:
They are in the midst of a major re-architecting of their
Corporate Management system utilizing many cutting edge
technologies. As it relates to the position they are using Flex as
their UI.
This is either a contract, or a full-time position.
Pay: Market Rate
Thanks for your help!
Natalie Fay
Outsource Technical
www.ostechnical.com
[email protected]
858.874.5637 -
WPF Finding Selected ComboBox Item Within DataGrid
Hi all... I'm having an issue trying to access the selected item value in a ComboBox within a DataGridTemplateColumn.
Through another question/answer I have got the ComboBox displaying the names as it should but the next step I'm having issues with is to be able to loop through each row in the DataGrid and determine the selected value of the ComboBox in that row as
well as some other items and run some other code based on those values.
Any help would be appreciated.
Thanks,
Greg
<Grid>
<DataGrid x:Name="gvDefaultCWWSchedule" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10,109,10,214" AutoGenerateColumns="False" Grid.Row="0"
AllowDrop="True" IsReadOnly="False" SelectionMode="Single" Background="Beige" CanUserAddRows="False">
<DataGrid.Columns>
<DataGridTemplateColumn Width="150">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox Name="ddlUsers"
ItemsSource="{Binding Path=Users}"
DisplayMemberPath="{Binding Name, Mode=TwoWay}"
SelectedValuePath="{Binding Uid, Mode=TwoWay}"
SelectedIndex="{Binding Uid, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
SelectionChanged="ComboBox_SelectionChanged"
>
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" />
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Binding="{Binding WeekNumber}" />
</DataGrid.Columns>
</DataGrid>
<Button Content="Button" HorizontalAlignment="Left" Margin="729,32,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/>
</Grid>
public partial class Test : Window
public Test()
InitializeComponent();
BindDefaultCWWSchedule();
private void BindDefaultCWWSchedule()
// THIS IS COMING FROM MY DB
List<CurrentUser> UsersFinal = new List<CurrentUser>();
UsersFinal.Add(new CurrentUser { Uid = 1, Name = "JOHN" });
UsersFinal.Add(new CurrentUser { Uid = 2, Name = "BILL" });
UsersFinal.Add(new CurrentUser { Uid = 3, Name = "MARY" });
ObservableCollection<CWWDefaultScheduleWeek> DefaultSchedules = new ObservableCollection<CWWDefaultScheduleWeek>();
DefaultSchedules.Add(new CWWDefaultScheduleWeek { Users = UsersFinal, WeekNumber = 1, SelectedUser = null });
DefaultSchedules.Add(new CWWDefaultScheduleWeek { Users = UsersFinal, WeekNumber = 2, SelectedUser = null });
DefaultSchedules.Add(new CWWDefaultScheduleWeek { Users = UsersFinal, WeekNumber = 3, SelectedUser = null });
DefaultSchedules.Add(new CWWDefaultScheduleWeek { Users = UsersFinal, WeekNumber = 4, SelectedUser = null });
gvDefaultCWWSchedule.ItemsSource = DefaultSchedules;
private void Button_Click(object sender, RoutedEventArgs e)
var rows = gvDefaultCWWSchedule.ItemsSource;
ObservableCollection<CWWDefaultScheduleWeek> CWWSchedAssignments = new ObservableCollection<CWWDefaultScheduleWeek>();
foreach (var row in rows)
CWWDefaultScheduleWeek r = (CWWDefaultScheduleWeek)row;
// FOR EACH ROW HERE I'M WANTING TO CREATE A LIST OF ITEMS AND RUN FURTHER CODE BASED ON IT... ISSUE IS FINDING THE ACTUAL SELECTED USER ON EACH ROW...
CWWSchedAssignments.Add(new CWWDefaultScheduleWeek
Users = r.Users,
SelectedUser = r.SelectedUser,
WeekNumber = r.WeekNumber
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
gvDefaultCWWSchedule.CommitEdit();
public class CWWDefaultScheduleWeek
public IEnumerable<CurrentUser> Users { get; set; }
public CurrentUser SelectedUser { get; set; }
public int WeekNumber { get; set; }
public class CurrentUser
public int Uid { get; set; }
public string Name { get; set; }In a way, wpf is similar to web.
More so than windows forms anyhow.
XAML is mark up and flows like html.
You have padding and margin which are rather familiar concepts.
Whereas windows forms is absolute positioning and... well totally different from markup.
You might find this sample interesting as a sort of mvvm taster.
https://gallery.technet.microsoft.com/WPF-Dialler-simulator-d782db17
and event handling equivalents
http://social.technet.microsoft.com/wiki/contents/articles/30564.wpf-uneventful-mvvm.aspx
Note
With a combo you bind the selecteditem to a propfull and then you can put a method call in the setter. That will then be invoked when the user changes selection.
Good luck and welcome to wpf development.
It's a great technology.
Hope that helps.
Recent Technet articles: Property List Editing;
Dynamic XAML -
How to use combobox to filter datagrid in Flash Builder 4?
Hi,
I've been working through the TestDrive application with Flash Builder 4 and I would like to learn how to filter a datagrid using a combobox. I've googled the subject and results for many different versions of Flash, some which look like they will take a considerable amount of time to implement. I'm hoping with Flash Builder 4 there is a straight-forward way to do this without writing pages of code.
I think I may be close to getting this working by passing the combobox value into a PHP script which queries the database with a WHERE clause.
Thakns,
DavidI was able to get the data returned from a PHP call into an array by placing the following in the service result handler:
public var myEmployeesArray : Array;
[Bindable]
public var myEmployeesDataProvider : ArrayCollection;
myEmployeesArray = mx.utils.ArrayUtil.toArray(event.result);
myEmployeesDataProvider = myEmployeesArray[0]; //data provider for the datagrid
Not certain how to use filterfunction yet though. I started to read this page but need to work on it more: http://cookbooks.adobe.com/post_Using_the_to_ArrayCollection_s_filterFunction-5441.html
I'd like to filter only one field in the ArrayCollection.
Also, for anyone else who may be learning while reading this, I found the following page helpful in figuring out how to load the PHP service return data into an array:
http://www.cflex.net/showFileDetails.cfm?ObjectID=415
David -
Displaying properties from two objects in a datagrid
Previously I post a discussion on this matter on Flex learning path and haven't got any response on how to do this so I figured that I might as well try again here.
I'm using drag and drop binding in flash builder 4 on a data-grid. However, the data I need to show need to be query from another object.
<mx:DataGrid id="dataGrid2" dataProvider="{getMajorDetailsResult.lastResult}">
<mx:columns>
<mx:DataGridColumn headerText="Category Name" />
<mx:DataGridColumn headerText="Require Credits" dataField="requireCredits" resizable="false" width="40"/>
</mx:columns>
</mx:DataGrid>
In this datagrid I bind it with an object MACL which has
- ID
- CAT_ID
- requireCredits
However, I would like to display CategoryName in the first column but categoryName is in another Object (category)
- CAT_ID
- CategoryName
In this case what should I do?
I did this so that if in the future Category Name needs to be rename. I can just rename the one in category table.
Any help is highly appreciated.
Thank youYou should use a model that references the two data sources to mae the one input to the DataGrid:
http://livedocs.adobe.com/flex/3/html/help.html?content=datamodels_3.html
If this post answers your question or helps, please mark it as such.
Greg Lafrance
www.ChikaraDev.com
Flex Development and Support Services -
[Help] How to merge two rows in a datagrid?
How to merge two rows of a specific column in a datagrid?
ex.
|_______|_____|_____|
| merged |_____|_____|
|_______|_____|_____|
|_______|_____|_____|
thx a lot~I need to merge column heading. Have u find any solution for
ur problem? -
Database driven combobox itemrenderer in DataGrid
Hi
I created a database driven combobox itemrenderer, code see below:
The data is loaded and shown correctly, but when I change the combobox, suddenly a "0" appears:
I can see in the debugger in combobox1_changeHandler, that the correct data is taken from the combo "this.selectedItem.data=3;" and written to "data.professionGroup", (changed from "1" to "3")
but then when the code jumps to set data the "value.professionGroup" is "0"?!?!
Thank yor for any pointers!
The DataGrid:
<mx:DataGrid id="personDg" dataProvider="{sm.persons}" width="100%" height="100%" editable="true">
<mx:columns>
<mx:DataGridColumn headerText="firstName" dataField="firstName"/>
<mx:DataGridColumn headerText="lastName" dataField="lastName"/>
<mx:DataGridColumn headerText="professionGroup" dataField="professionGroup" editable="true" editorDataField="data"
rendererIsEditor="true"
itemRenderer="com.xxx.view.components.combobox.ProfessionGroupCombo">
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
The ItemRenderer:
<?xml version="1.0" encoding="utf-8"?>
<mx:ComboBox xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo"
change="combobox1_changeHandler(event)" initialize="combobox1_initializeHandler(event)" >
<fx:Script>
<![CDATA[
import mx.controls.dataGridClasses.DataGridListData;
import com.myfim.model.ShellModell;
import mx.events.ListEvent;
import mx.events.FlexEvent;
[Bindable]
private static var sm:ShellModell=ShellModell.getInstance();
public function setSelectedItemByValue(val:int):void{
this.selectedIndex = -1; // Show prompt if value is not found
for (var i:int=0;i<this.dataProvider.length;i++){
if(this.dataProvider[i].data == val){
this.selectedIndex = i;
break;
}// for
override public function set data(value:Object):void{
super.data=value; // value is the VO!
setSelectedItemByValue(value.professionGroup);
protected function combobox1_changeHandler(event:ListEvent):void
data.professionGroup=this.selectedItem.data;
// I can see in the debugger that "data.professionGroup" gets the correct data f.e. ="3" , but if it jumps to the "set data" the value.professionGroup is "0" !??
protected function combobox1_initializeHandler(event:FlexEvent):void
this.dataProvider=sm.comboData.professionGroupAc; // AC of (label, data)
]]>
</fx:Script>
</mx:ComboBox>Hi,
yupiiee! I found the answer by myself, I had to change
editorDataField="data" to editorDataField="value"
Thats all! Then it works!
Martin Zach -
Error while creating a custom combobox for Spark DataGrid
I am getting the following run time error:
Error: Required skin part openButton cannot be found.
atspark.components.supportClasses::SkinnableComponent/findSkinParts() [E:\dev\hero_private_beta\frameworks\projects\spark\src\spark\componen ts\supportClasses\SkinnableComponent.as:671]
atspark.components.supportClasses::SkinnableComponent/attachSkin()[E: \dev\hero_private_beta\frameworks\projects\spark\src\spark\components\ supportClasses\SkinnableComponent.as:646]
atspark.components.supportClasses::SkinnableComponent/validateSkinCha nge()[E:\dev\hero_private_beta\frameworks\projects\spark\src\spark\com ponents\supportClasses\SkinnableComponent.as:406]
atspark.components.supportClasses::SkinnableComponent/commitPropertie s()[E:\dev\hero_private_beta\frameworks\projects\spark\src\spark\compo nents\supportClasses\SkinnableComponent.as:420]
atspark.components.supportClasses::ListBase/commitProperties()[E:\dev \hero_private_beta\frameworks\projects\spark\src\spark\components\supp ortClasses\ListBase.as:808]
atspark.components::List/commitProperties()[E:\dev\hero_private_beta\ frameworks\projects\spark\src\spark\components\List.as:954]
atspark.components.supportClasses::DropDownListBase/commitProperties( )[E:\dev\hero_private_beta\frameworks\projects\spark\src\spark\compone nts\supportClasses\DropDownListBase.as:504]
atspark.components::ComboBox/commitProperties()[E:\dev\hero_private_b eta\frameworks\projects\spark\src\spark\components\ComboBox.as:644]
atmx.core::UIComponent/validateProperties()[E:\dev\hero_private_beta\ frameworks\projects\framework\src\mx\core\UIComponent.as:8095]
atmx.managers::LayoutManager/validateClient()[E:\dev\hero_private_bet a\frameworks\projects\framework\src\mx\managers\LayoutManager.as:934]
atmx.core::UIComponent/validateNow()[E:\dev\hero_private_beta\framewo rks\projects\framework\src\mx\core\UIComponent.as:7953]
atspark.components.supportClasses::GridLayout/layoutItemRenderer()[E: \dev\hero_private_beta\frameworks\projects\spark\src\spark\components\ supportClasses\GridLayout.as:1808]
atspark.components.supportClasses::GridLayout/createTypicalItemRender er()[E:\dev\hero_private_beta\frameworks\projects\spark\src\spark\comp onents\supportClasses\GridLayout.as:460]
atspark.components.supportClasses::GridLayout/updateTypicalCellSizes( )[E:\dev\hero_private_beta\frameworks\projects\spark\src\spark\compone nts\supportClasses\GridLayout.as:514]
atspark.components.supportClasses::GridLayout/layoutColumns()[E:\dev\ hero_private_beta\frameworks\projects\spark\src\spark\components\suppo rtClasses\GridLayout.as:570]
atspark.components.supportClasses::GridLayout/measure()[E:\dev\hero_p rivate_beta\frameworks\projects\spark\src\spark\components\supportClas ses\GridLayout.as:230]
atspark.components.supportClasses::GroupBase/measure()[E:\dev\hero_pr ivate_beta\frameworks\projects\spark\src\spark\components\supportClass es\GroupBase.as:1109]
atmx.core::UIComponent/measureSizes()[E:\dev\hero_private_beta\framew orks\projects\framework\src\mx\core\UIComponent.as:8383]
atmx.core::UIComponent/validateSize()[E:\dev\hero_private_beta\framew orks\projects\framework\src\mx\core\UIComponent.as:8307]
atspark.components::Group/validateSize()[E:\dev\hero_private_beta\fra meworks\projects\spark\src\spark\components\Group.as:956]
atmx.managers::LayoutManager/validateSize()[E:\dev\hero_private_beta\ frameworks\projects\framework\src\mx\managers\LayoutManager.as:659]
atmx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\hero_priv ate_beta\frameworks\projects\framework\src\mx\managers\LayoutManager.a s:793]
atmx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\h ero_private_beta\frameworks\projects\framework\src\mx\managers\LayoutM anager.as:1157]
Here is my combobox:
package
import mx.controls.listClasses.BaseListData;
import mx.controls.listClasses.IDropInListItemRenderer;
import spark.components.ComboBox;
public class sparkComboRendererDataGrid extends ComboBox implements IDropInListItemRenderer
public function sparkComboRendererDataGrid()
super();
public function get listData():BaseListData
return null;
public function set listData(value:BaseListData):void
override public function set dataProvider(value:Object):void
super.dataProvider = value;
// This may get called before dataProvider is set, so make sure not null and has entries
if (value!=null && value.length)
// Got it, set flag
bDataProviderSet = true;
and here is the implementation:
var PersonnelPerson:ClassFactory = new ClassFactory(sparkComboRendererDataGrid);
PersonnelPerson.properties = {labelField : "person", dataProvider :
new XMLListCollection(dataList.consistcrew)};
var col:GridColumn = GridColumn(personnel.columns.getItemAt(0));
col.itemRenderer = PersonnelPerson;
Please help.
ThanksActually, after adding the following code it started working:
import spark.skins.spark.DropDownListSkin;
override public function stylesInitialized():void
super.stylesInitialized();
this.setStyle("skinClass", DropDownListSkin); -
Comparing two columns in a datagrid.
I have a datagrid that has a data provider of some users. The users have a name, address, balance, and payment amount. For the payment amount I'm using a custom MXDataItemRenderer as my TextEditor (not text renderer). What I want to do is validate that the amount they entered in the payment amount is not greater than the balance.
I've been trying to do this on an itemEditEndHandler, but the problem is that for some reason I don't have the payment amount at that time. I'm wondering what I'm doing wrong or if I'm going about this completely the wrong way.
Any help would be greatly appreciated.
Thanks
Here is my editHandler function
var item:Object = ((event.currentTarget as DataGrid).dataProvider as ArrayCollection)[event.rowIndex];
var paymentValidator:PaymentAmountValidator = new PaymentAmountValidator(item.balance);
paymentValidator.source = this.dataProvider;
paymentValidator.property = "paymentAmount";
paymentValidator.validate(item.paymentAmount);
Here is my custom validator.
public class PaymentAmountValidator extends Validator
private var results:Array;
private var balance:Number;
public function PaymentAmountValidator(balance:Number = 0){
super();
this.balance = balance;
// Define the doValidation() method.
override protected function doValidation(value:Object):Array {
// Convert value to a Number.
var inputValue:Number = Number(value);
// Clear results Array.
results = [];
// Call base class doValidation().
results = super.doValidation(value);
// Return if there are errors.
if (results.length > 0)
return results;
// If input value is not a number, or contains no value,
// issue a validation error.
if (isNaN(inputValue) || !value )
results.push(new ValidationResult(true, null, "NaN",
"You must enter an amount."));
return results;
if (inputValue > balance) {
results.push(new ValidationResult(true, null, "moreThanBalance",
"Payment amount must be less than or equal to balance."));
return results;
return results;Thanks for the answer. I ended up doing it a little differently and instead of catching the itemEditEnd event I added my custom validator to the actual renderer itself, but your advice to use the itemEditorInstance got me the data I needed.
My validation looked like this before moving it to the custom item editor.
var item:Object = ((event.currentTarget as DataGrid).dataProvider as ArrayCollection)[event.rowIndex];
var amountText:String = AmountTextInputRenderer(this.itemEditorInstance).amountText;
var paymentValidator:PaymentAmountValidator = new PaymentAmountValidator(parseFloat(amountText));
paymentValidator.source = item;
paymentValidator.property = "paymentAmount";
paymentValidator.validate(item.paymentAmount); -
Dear Experts,
I'm developing a dashboard whose query accepts two parameters.
So I have 2 combo boxes one for each parameter. Say One for Criteria and other for Percentage
Problem Is:
Say IF I select 10 in Percentage Combo and then Select Value in Criteria Combo It shows the chart with everything ok.
No If I don't change the Percentage combo and only select or change value in the Criteria combo it again gives me the correct result what ever is expected.
But If I keep the Value in Criteria combo box constant and only changes the percentage value, it doesn't reflect any changes.
If I make change to Percentage combo as well as Criteria combo then it shows the result.
I don't understand what could be the problem for this behaviour.
Any inputs will be appreciated
ThanksHi
Just Noticed that problem is where we assign the cell to Trigger i.e. Under Usage tab. (I think.)
Regards -
Can these two functionalities work on datagrid?
Hi everyone,
I have a datagrid (shopping card) which has 3 columns such as
ProductName, Quantity, Details.
Part 1: Once the user click on the Quantity, then the user is
allowed to make changes on the quantity.
Part 2: Once the user click on the Details, then the code
will get to another state which shows the product details.
Part 1 is done. But Part is is not done yet. Any idea how to
get Part 2 done is greatly appreciated. Thanks.
Note for Part 2. If the user click on the Details on row 1,
then the code show product 1 details. If the user click on
Details on row 2, then the code show product 2 details, ...
etc.
Thanks,
Mayquote:
Originally posted by:
Mirza Asim
in the 'itemEditBegin' event handler, if 'event.columnIndex'
is the index of 'Detail' column, then take the row of dataProvider
at the index 'event.rowIndex' and do whatever you want with it. If
you want to change the state then change the state and pass this
information of row data to that state.
I tried my best to understand your question and then replied
accordingly. But if my answer is not very clear to you then please
tell me, what exactly you want.
Hi Mirza,
Thanks for your help. Yes what you are saying is exactly what
I want to do. But I cannot change the state (see LINE XYZ). Please
see the code and error message below. Thanks.
May
// Handle the itemEditBegin event.
private function modifyEditedData(event:DataGridEvent):void
// Get the name of the column being editted.
var colName:String =
myDataGrid.columns[event.columnIndex].headerText;
if(colName=="Product Details")
trace(_myShoppingCardArrayCollection.getItemAt(event.rowIndex).ProductCode);
_productCode_temp =
_myShoppingCardArrayCollection.getItemAt(event.rowIndex).ProductCode;
//currentState = "ProductDetailsFromShoppingCard"; //<==
This line gives error (LINE XYZ).
private function updateQuantity():void {
var iQty:int = 0;
var qty:String = "";
for (var
i:int=0;i<_myShoppingCardArrayCollection.length;i++) {
trace(_myShoppingCardArrayCollection.getItemAt(i).Quantity);
qty += _myShoppingCardArrayCollection.getItemAt(i).Quantity
+ "\r";
iQty +=
parseInt(_myShoppingCardArrayCollection.getItemAt(i).Quantity);
trace("Qty:" + iQty)
Alert.show(qty);
<mx:DataGrid id="myDataGrid"
dataProvider="{_myShoppingCardArrayCollection}"
editable="true"
itemEditBegin="modifyEditedData(event);"
rowHeight="60">
<mx:columns>
<mx:DataGridColumn headerText="Product Name"
dataField="ProductName" textAlign="left" wordWrap="true"
editable="false" />
<mx:DataGridColumn headerText="Product Price"
dataField="ProductPrice" textAlign="center" editable="false" />
<mx:DataGridColumn headerText="Quantity"
dataField="Quantity" editable="true" />
<mx:DataGridColumn headerText="Product Details"
dataField="ProductCode" editable="true" />
</mx:columns>
</mx:DataGrid>
<mx:Button label="Update" click="updateQuantity()" />
--------------------------------- end --------------------
TypeError: Error #1009: Cannot access a property or method of
a null object reference.
at
mx.controls::DataGrid/createItemEditor()[E:\dev\3.0.x\frameworks\projects\framework\src\m x\controls\DataGrid.as:3884]
at
mx.controls::DataGrid/itemEditorItemEditBeginHandler()[E:\dev\3.0.x\frameworks\projects\f ramework\src\mx\controls\DataGrid.as:4747]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at
mx.core::UIComponent/dispatchEvent()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\co re\UIComponent.as:9051]
at
mx.controls::DataGrid/commitEditedItemPosition()[E:\dev\3.0.x\frameworks\projects\framewo rk\src\mx\controls\DataGrid.as:3676]
at
mx.controls::DataGrid/updateDisplayList()[E:\dev\3.0.x\frameworks\projects\framework\src\ mx\controls\DataGrid.as:1498]
at
mx.controls.listClasses::ListBase/validateDisplayList()[E:\dev\3.0.x\frameworks\projects\ framework\src\mx\controls\listClasses\ListBase.as:3281]
at
mx.managers::LayoutManager/validateDisplayList()[E:\dev\3.0.x\frameworks\projects\framewo rk\src\mx\managers\LayoutManager.as:602]
at
mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\3.0.x\frameworks\projects\frame work\src\mx\managers\LayoutManager.as:675]
at Function/
http://adobe.com/AS3/2006/builtin::apply()
at
mx.core::UIComponent/callLaterDispatcher2()[E:\dev\3.0.x\frameworks\projects\framework\sr c\mx\core\UIComponent.as:8460]
at
mx.core::UIComponent/callLaterDispatcher()[E:\dev\3.0.x\frameworks\projects\framework\src \mx\core\UIComponent.as:8403]
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick() -
Set Combobox value based on Datagrid selectedItem
I have been searching the forums and google for some time now
and I'm not sure how do this. I populate a datagrid from a
httpservice call to a php script. The datagrid is displaying
perfectly. I also populate two comboboxes from the same httpservice
with specific values. When I select a row in the datagrid, I'd like
the value of the combobox to change to that which corresponds to
the value from the datagrid.
I also have a few TextInput fields mixed in with the
comboboxes and I'm able to set those to the
datagridname.selectedItem.item. I would like to do the same for the
comboboxes.
The reason is so that I can edit users in a group within a
database. The comboboxes are for the specific groups that are
allowed to all users.
Please let me know if any other information is necessary. I
didn't think any of my current code would help with this question.
Any examples would be great, I just couldn't find any....
Thanks in advance for your time.
ChrisTracy - I think I'm progressing, but I'm still running into
problems. I've changed the httpservice to call an eventhandler,
which in turn I use in the datagrid to populate it. I'm sure I
might need to change something, but it is working.... Once I get it
all working, I'll stop using lastResult and build event handlers,
now that I'm starting to get a better grasp on it.
I do get an error though, stating: "Data binding will not be
able to detect changes to XMLList "user", need an XML instance."
Also, I can't seem to get "trace" to work. I'm guessing it should
be popping up a window? If I do an alert popup, it does show the
data.
[Bindable]private var myData:XMLList;
private function test(oEvent:ResultEvent):void {
myData = XMLList(oEvent.result);
trace(myData.toXMLString());
mx.controls.Alert.show(myData);
<mx:HTTPService id="getUsers"
url="https://server/flex/getusers.php" resultFormat="e4x"
result="test(event)" useProxy="false" method="GET"/>
<mx:DataGrid id="dgUserDetails" right="5"
dataProvider="{myData.user}" height="315"
click="onChangeUser(event)">
<mx:columns>
<mx:DataGridColumn headerText="Username"
dataField="uname"/>
<mx:DataGridColumn headerText="Group"
dataField="team"/>
<mx:DataGridColumn headerText="Status"
dataField="status"/>
<mx:DataGridColumn headerText="Last Login"
dataField="llogin"/>
<mx:DataGridColumn headerText="Count"
dataField="lcount"/>
</mx:columns>
</mx:DataGrid>
Now, onto the user editing fields. I'm still trying to figure
out how to use this example you gave me. I understand the xmlUser
var and I think I understand the xlGroups var. Not sure how it
should work though. It looks as though xlGroups tries to get the
group from allusers under the user name?
[Bindable]private var _xlcGroups:XMLListCollection;
private function onChangeUser(oEvent:Event):void {
var xmlUser:XML = XML(dgUserDetails.selectedItem); //the
Users dataProvider item
var xlGroups:XMLList = xmlUser.allusers.group; //this
depends on your xml structure
_xlcGroups = new XMLListCollection(xlGroups)
trace(_xlcGroups.toXMLString() ); //so you can see exactly
what you have
Let me try to give a better example of the XML.
<allusers>
<user>
<uname>user1</uname>
<level>6</level>
<status>active</status>
<team>alpha</team>
<llogin>0000-00-00 00:00:00</llogin>
<lcount>0</lcount>
</user>
<user>
<uname>user2</uname>
<level>6</level>
<status>active</status>
<team>alpha</team>
<llogin>2007-03-26 11:31:53</llogin>
<lcount>128</lcount>
</user>
<user>
<uname>user3</uname>
<level>1</level>
<status>active</status>
<team>bravo</team>
<llogin>2006-02-17 20:08:23</llogin>
<lcount>3</lcount>
</user>
<group>
<teamname>alpha</teamname>
<teamlead>user2</teamlead>
<teamstatus>active</teamstatus>
</group>
<group>
<teamname>bravo</teamname>
<teamlead>user3</teamlead>
<teamstatus>active</teamstatus>
</group>
<statusops>
<status>active</status>
</statusops>
<statusops>
<status>inactive</status>
</statusops>
</allusers>
And here is a more detailed view of the user editing panel.
Again, I always want the comboboxes to display the data returned
from the httpservice call. But I want to change the value when the
user is selected.
<mx:Panel width="250" height="315" left="5"
layout="absolute" title="User Details">
<mx:HBox x="10" y="27" width="210">
<mx:Label text="Username" width="65"/>
<mx:TextInput id="adm_username" width="137"
text="{dgUserDetails.selectedItem.uname}"/>
</mx:HBox>
<mx:HBox x="10" y="55" width="210">
<mx:Label text="Group" width="65"/>
<mx:ComboBox id="adm_usergroup" width="137"
dataProvider="{getUsers.lastResult.allusers.group}"
labelField="teamname"/>
</mx:HBox>
<mx:HBox x="10" y="83" width="210">
<mx:Label text="Level" width="65"/>
<mx:TextInput id="adm_level" width="137" maxChars="1"
text="{dgUserDetails.selectedItem.level}"/>
</mx:HBox>
<mx:HBox x="10" y="111" width="210">
<mx:Label text="Status" width="65"/>
<mx:ComboBox id="adm_activestatus" width="137"
dataProvider="{getUsers.lastResult.allusers.statusops}"
labelField="status"/>
</mx:HBox>
<mx:HBox x="10" y="137" width="210">
<mx:Label text="Password" width="65"/>
<mx:TextInput id="adm_password" width="137" enabled="true"
backgroundDisabledColor="#C0C0C0" displayAsPassword="true"
change="adm_chkusr(adm_password)"/>
</mx:HBox>
<mx:HBox x="10" y="165" width="210">
<mx:Label text="Confirm" width="65"/>
<mx:TextInput id="adm_confirm" width="137" enabled="false"
backgroundDisabledColor="#C0C0C0" displayAsPassword="true"
change="adm_chkusr(adm_confirm)"/>
</mx:HBox>
<mx:HBox x="10" y="205" width="210">
<mx:HBox width="50%">
<mx:LinkButton id="adm_clruser" label="Clear"
click="clearviewUser()"/>
</mx:HBox>
<mx:HBox width="50%">
<mx:LinkButton id="adm_moduser" label="Modify User"
enabled="false"/>
</mx:HBox>
</mx:HBox>
<mx:HBox x="10" y="233" width="210">
<mx:HBox width="50%">
<mx:LinkButton id="adm_deluser" label="Delete User"
enabled="false"/>
</mx:HBox>
<mx:HBox width="50%">
<mx:LinkButton id="adm_adduser" label="Add User"
enabled="false"/>
</mx:HBox>
</mx:HBox>
</mx:Panel>
Thanks again for your time. I look forward to your response
as this is driving me crazy.
Regards,
Chris
Maybe you are looking for
-
What cords do i need to hook up my macbook to my tv?
what cords do i need to purchase in order to watch movies from my macbook to my tv?
-
Movement type for issuing materials from project stock to vendor
Hello gurus, after making GRN, the stock is updated in Project stock. now from the project stock, i want to issue the materials to vendor. which MvT i have to use and where it displays the Vendor. i need to track the materilas provided to vendor. tn
-
I have one ITAB having following values: GRN IR Date Price 11249432 6075620 31.07.2007 1082104 11249433 6075620 31.07.2007 1082104 11249436 6075620 31.07.2007 1082104 But i wish to wr
-
AUR3 [aur-pyjs] implementation in python (pyjs) + JSON-RPC
Welcome to AUR3. available (pre-alpha)... http://aur.archlinux.org/packages.php?ID=38359 QUICKSTART 1) install # http://aur.archlinux.org/packages.php?ID=38359 2) run # /usr/lib/aur-pyjs-git/aur serve -f 3) view # http://127.0.0.1:8000
-
guyz i need your help i forgot my answers to my security questions and i dont know what to do pls. help me i really need help and my account has been locked for 8 hours. any ideas on how can i reset my security questions pls reply thanks