我有一个填充信息数组的数据网格。数据网格由用户使用,因此他们可以在数据网格上添加记录或删除记录。示例:如果用户添加以下信息:“名称:Apples / 描述:水果” 如果此信息已存在于数据网格中,我如何防止他们再次添加它?可能会提示“此项目已列出,请重试”。任何人对我如何使代码对我有利的任何想法?
功能:
        public function addRow():void {
        var st:AttributeVO = AttributeVO(attCombo.selectedItem);
        st.countryCode = countriesAvailable.selectedLabel;
        var nt:AttributeVO = st.clone();
        var list:ArrayCollection = model.selectedCategory.tai;
        nt.attributeValue = "";
        list.addItem(nt);
        templatePropertiesDG.invalidateList();
    }
    <mx:HBox>
            <mx:ComboBox  id="attCombo" dataProvider="{model.selectedCategory.completeList}" width="300" prompt="Select a Template Attribute" enabled="{model.userInEditMode}" labelField="attributeName" />
            <mx:Button id="addButton" click="addRow();" styleName="addButtonOff" enabled="{model.userInEditMode}" label="ADD" />
    </mx:HBox>
    <mx:DataGrid id="templatePropertiesDG" dataProvider="{model.selectedCategory.tai}" width="100%" height="100%" editable="{model.userInEditMode}">
      <mx:columns>
        <mx:DataGridColumn id="Name" dataField="Name" headerText="Name" width="25" editable="false"/>
        <mx:DataGridColumn id="Value" dataField="Value" headerText="Value" width="25" editable="{model.userInEditMode}"/>
        <mx:DataGridColumn id="Country" dataField="Code" headerText="Country" width="10" editable="false"/>
        <mx:DataGridColumn id="Info" dataField="Info" headerText="Information" width="40" editable="false"/>
      </mx:columns>
    </mx:DataGrid>