Count the number of times an item has been clicked.

In the data grid if an item is clicked I would like to know.  Example: if i click the third item in the data grid 2 times I would like a field where the selected item is to count those clicks, that field would display 2.  If i click the first item in the data grid 4 times I would like a field where the selected item is to count those clicks, that field would display 4.

Is this possible?
aduvallAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MaartenHensenCommented:
Am only started flex ( 4 in my case a few days ago) but I used " itemClick="rowclick(event)" " as a datagrid attribute for something similar I guess.

You then create that function:

private function rowclick(event:ListEvent):void {
      item = event.rowIndex;
}

Now you only need to use that function to populate an array and you can again output that array.

At least thats the way, I as a beginner, would do it.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
IqAndreasCommented:
How are you creating and populating this data grid. It would be easier if you upload a sample project that I could open and mess around with.

Will you be changing and sorting the items in the grid, or will they remain the same throughout? This may have an impact on the resulting code.

However, if you do as MaartenHensen described and set the "itemClick" property, change the rowclick function to something like the attached code.


Just ask if you have any questions,
Andreas
private var timesClicked:Array = new Array();
private function rowclick(event:ListEvent):void {
    timesClicked[event.rowIndex] = int(timesClicked[event.rowIndex]) + 1;
}


//Retrieve the value like this:
trace(timesClicked[<row number>]);

Open in new window

0
aduvallAuthor Commented:
 Hello, the array collection below does not change and supplies data to the dg below.  I just need to know how many times an item has been clicked and have it displayed in the Quant column.

<mx:ArrayCollection id="myData">
        <mx:source>
            <mx:Array>
                <mx:Object item="1" descrip="test" quant="1"  price="140" isSelected = "false"/>
               
                <mx:Object item="2" descrip="test a" quant="1"  price="140" isSelected = "false"/>
               
               
                <mx:Object item="3" descrip="test b" quant="1"  price="285" isSelected = "false"/>
             
                <mx:Object item="4" descrip="test c" quant="1"  price="140" isSelected = "false"/>
               
            </mx:Array>
        </mx:source>
    </mx:ArrayCollection>

      <mx:DataGrid x="28" y="26" id="grid" itemEditEnd="rowclick(event);" dataProvider="{myData}" alpha="1.0" borderStyle="none" alternatingItemColors="[#FFFFFF, #FFFFFF]" borderColor="#FFFFFF" color="#000000" click="upGrade();" width="753" themeColor="#82C7DB">
            <mx:columns>
                  <mx:DataGridColumn headerText="Item#" dataField="item"/>
                  <mx:DataGridColumn headerText="Description" dataField="descrip"/>
                  <mx:DataGridColumn headerText="Price" dataField="price"/>
                  <mx:DataGridColumn headerText="Quant" }"/>

0
IqAndreasCommented:
There seems to be missing a chunk of code from that.

Do you think you could upload the entire project as a ZIP file?

That makes it a lot easier to help you out. :)
0
aduvallAuthor Commented:
Thank You!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.