header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
krishna
Points:260
Posts:0

5/26/2010 3:41:43 AM

Title: datagrid duplicates


Hi,

I have two datagrids and one button, Whenever I click button the popupdatagrid comes, then i willl add three rows(10 record, 11th record, 12th record), Again i am clicking add
button and i add 12th record, it will be adding but i dont want to add , it will gives an alert.
How to do it, Please help me

Thanks in advance
Ramakrishna



1
Juan
Points: 0
Posts:0
5/26/2010 4:40:04 AM



if you want to restrict the records upto 11th. Then you can put the condition before adding the code which checks the length of dataProvider and shows alert instead of adding the record.i.e


if(dataProvider.length<11){
//here goes your code which adds record to data grid
}else{
alert.show("You are not allowed to add the 12th record.")
}


2
Rama
Points: 0
Posts:0
5/26/2010 8:43:57 PM



hi,

I am asking about duplicate records. not length?

Thanks in advance
Rama

3
Evan
Points: 0
Posts:0
5/26/2010 10:54:09 PM



write a loop to check if the record exists in the datagrid if not then add it. You need to check for some unique variable that exists in your records. Like your record is
Type Value
---------------
Fruits Apple
Fruits Banana
Fruits Orange

You should check for "Value" here


// replace this code by code where you are adding the new record on button click

var newRecordUniqueVariable= Record.value;
var recordFound:Boolean=false:
for(var i:int;i<dataprovider.length;i++){

if(dataprovider[i].value == Record.value){
recordFound=true;
}
}
if(recordFound==true{
//show alert record cannot be added
}else{

//add the record
}
}



Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 8+2 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions