0

The question seems to be simple, however it create problems for me. I have a dataGrid with two dataFields: peerID, name. The information in a grid updated dynamically when new user joined the group (I'm creating a chat). I need that information about user deleted from a grid after it's disconnect.

So, on "NetGroup.Neighbor.Disconnect": event i want to compare "event.info.peerID" value with all peerID values in a grid and delete info about disconnected user.

I'm trying to use next construction:

for (var i:uint, len:uint = txtDataArray.length; i < len; i++)
                        {
                        if (txtDataArray.source[i] == event.info.peerID)
                        {
                            txtDataArray.removeItemAt(i);
                        break;
                        }
                            }



<s:DataGrid id="txtData" x="11" y="59" width="238" height="164" alternatingRowColors="[ #67676767, #555555]" borderVisible="true" chromeColor="#555555" color="#CCCCCC" contentBackgroundColor="#555555" dataProvider="{callerns}" fontWeight="bold" requestedRowCount="4" rollOverColor="#08700D" selectionColor="#08700D" symbolColor="#CCCCCC">
        <s:columns>
            <s:ArrayList id="txtDataArray">
                <s:GridColumn dataField="name" headerText="USERS ONLINE"></s:GridColumn>
                <s:GridColumn dataField="peerID" headerText="USER ID" visible="true"></s:GridColumn>
            </s:ArrayList>
        </s:columns>
    </s:DataGrid>

But it doesn't work at all!

I'v noticed that construction txtDataArray.source[i] (or txtDataArray.getItemAt(i) ) returned [object GridColumn] insead of value. So, I have two questions: 1) How to get the value of exact cell? 2) How to organized info delete after user disconnect?

Thank you in advance!

Ievgenii
  • 67
  • 8

1 Answers1

0

Why are you using txtDataArray.source[i]?
You can write like this:

    for (var i:int; i < callerns.length; i++)
    {
        if (callerns[i].peerID == event.info.peerID)
        {
            callerns.removeItemAt(i);
            break;
        }
    }

or use for each if you want.
By the way, I like your datagrid's style.

randomUser56789
  • 936
  • 2
  • 13
  • 32
  • Thank you very mach! I spend half of the day truing to solve this simple problem! You save lots of my time. It seems to be easier to do whole chat functionality than solve this small question. I'm using the same style for whole chat which is planed as an communication tool for students from different universities. You may see Beta version here: http://www.koondoo.com/index.php/chat . It's not 100% complete but main functionality are work. Thank you again! – Ievgenii Feb 20 '12 at 12:36