[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.4

Flex and ActionScript 3 -  Selecting a Checkbox and deleting a data grid row

Asked by jrwalker2 in Adobe Flex, Scripting Languages, Web Languages/Standards

I want be able to delete a datagrid row AND rows out of a data grid if a checkbox is checked. The checkbox is part of the row (the first cell). Right now I cannot detect if the checkbox is selected or not after it has been sent to the datagrid. I would like to check which rows are checked and then remove all of the rows that have a selected check box (call removeTaskRecord()). How can I do this? I just started learning Flex, so all suggestions with accompanied code are appreciated. Thanks
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FDFDFD, #FDFCFC]">
    <mx:Script>
        <![CDATA[
            
            import mx.collections.ArrayCollection;
            import mx.controls.List;
            import mx.controls.CheckBox;    
            import mx.controls.ComboBox;
            
            [Bindable]    
            private var myArray1:Array = new Array("a", "b", "c");
            
            [Bindable]    
            private var myArray2:Array = new Array("a", "b", "c");
            
            [Bindable]    
            private var myArray3:Array = new Array("a", "b", "c");
            
 
            [Bindable]
            private var dataGridProvider:ArrayCollection = new ArrayCollection();
            
            
            [Bindable]
            private var selectCheckBox:CheckBox = new CheckBox();
            
            private var cb:ComboBox = new ComboBox();
            
            
            private function updateTable():void
            {
                //Add the new data into the table (into the next row of the table)
                dataGridProvider.addItem({col1:selectCheckBox, col2:cb1.selectedLabel,col3: input1.text, col4:cb2.selectedLabel,
                 col5:ns1.value ,col6:cb3.selectedLabel, col7:ns2.value});
 
                //Update the table's dataprovider with the updated task row
                table.dataProvider = dataGridProvider;
                
                //Clear the data from the new task input form 
                cb1.selectedIndex = -1;
                input1.text = null;
                cb2.selectedIndex = -1;
                ns1.value = 0;
                cb2.selectedIndex = -1;
                ns2.value = 0;
            }
            
            private function removeTaskRecord():void
            {
                //Check if the checkbox for the task is selected 
                //((CheckBox)(((Array)(dataGridProvider.getItemIndex(scrumTable.selectedIndex)))[0])).selected
                if(table.selectedIndex>=0)//selectCheckBox.selected)//if(datagrid selected index is greater than or equal to 0)
                {
                    //Remove the task record from the Data Grid data provider
                    dataGridProvider.removeItemAt(table.selectedIndex);    
 
                }
                
                
                
            }
            
        
            
        ]]>
    </mx:Script>
    
    <mx:Panel width="1027" height="382" layout="absolute" borderColor="#0C2B73" left="10" bottom="10">
        <mx:DataGrid x="10" y="10" width="984" height="295" wordWrap="true" id="table" dataProvider="{dataGridProvider}" draggableColumns="false" variableRowHeight="true">
            <mx:columns>
                <mx:DataGridColumn headerText="col1" dataField="col1" editable="true" itemRenderer="mx.controls.CheckBox" width="50" textAlign="center"/>
                <mx:DataGridColumn headerText="col2" dataField="col2"  editable="true" itemRenderer="mx.controls.TextInput"/>
                <mx:DataGridColumn headerText="col3" dataField="col3" editable="true" itemRenderer="mx.controls.TextInput"/>
                <mx:DataGridColumn headerText="col4" dataField="col4" editable="true" itemRenderer="mx.controls.TextInput"/>
                <mx:DataGridColumn headerText="col5" dataField="col5" editable="true" itemRenderer="mx.controls.NumericStepper"/>
                <mx:DataGridColumn headerText="col6" dataField="col6" editable="true" itemRenderer="mx.controls.TextInput"/>
                <mx:DataGridColumn headerText="col7" dataField="col7" editable="true" itemRenderer="mx.controls.NumericStepper"/>
            </mx:columns>
        </mx:DataGrid>
        <mx:Button x="921" y="313" label="Remove" id="removeBtn" enabled="true" click="removeTaskRecord()"/>
    </mx:Panel>
    <mx:Panel width="520" height="308" layout="absolute" left="10" top="33" borderColor="#0C2B73">
        <mx:ComboBox x="10" y="40" id="cb1" dataProvider="{myArray1}" width="169" selectedIndex="-1"></mx:ComboBox>
        <mx:TextInput x="202" y="40" width="255" id="input1"/>
        <mx:ComboBox x="10" y="107" dataProvider="{myArray2}" selectedIndex="-1" id="cb2"></mx:ComboBox>
        <mx:ComboBox x="202" y="107" dataProvider="{myArray3}" selectedIndex="-1" id="cb3"></mx:ComboBox>
        <mx:NumericStepper x="10" y="179" maximum="25" id="ns1"/>
        <mx:NumericStepper x="202" y="179" maximum="25" id="ns2"/>
        <mx:Button x="392" y="218" label="Submit"  id="sbBtn" click="updateTable()"/>
    </mx:Panel>
 
    
</mx:Application>
 
Related Solutions
Keywords: Flex and ActionScript 3 - Selecting a…
 
Loading Advertisement...
 
[+][-]03/17/08 01:11 AM, ID: 21140415Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Adobe Flex, Scripting Languages, Web Languages/Standards
Sign Up Now!
Solution Provided By: hobbit72
Participating Experts: 4
Solution Grade: A
 
[+][-]03/13/08 08:29 AM, ID: 21117197Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/16/08 01:57 PM, ID: 21138430Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 / EE_QW_2_20070628