情報の配列を設定するデータグリッドがあります。データグリッドはユーザーが使用するため、ユーザーはデータグリッドでレコードを追加または削除できます。例: ユーザーが次の情報を追加した場合: 「名前: りんご / 説明: 果物」 この情報がデータグリッドに既に存在する場合、どうすれば再度追加できないようにできますか? 「このアイテムは既にリストされています。もう一度お試しください」というプロンプトが表示される場合があります。コードを有利に機能させる方法について、誰かからの考えはありますか?
機能性:
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>