Pergunta

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!

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top