Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > Adobe Web Programming > Flex
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Flex Discuss the Adobe Flex programming language
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Flex section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old May 25th, 2009, 01:17 AM
Registered User
 
Join Date: May 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to edit cell in a Data Grid

Hai

I need to edit a particular cell in a datagrid.

I have attched the sample code below , pl run the mxml and help me to edit a cell in datagrid.

1. If u run the mxml , enter some values in the textbox and click add button and then Clik AND or Or then again change the second combobox,

2. Again add some values to the textbox and click add, now u can see the values in the datagrid.

3. I need to be edited a particular cell in that datagrid. say in that Value Column should be clicked and then that particular cell alone should be edited.

Can any one help me.

Thanks in Advance :)

Sample Code:

[code]

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

<mx:Script>


<![CDATA[

// ActionScript file

import
mx.rpc.events.FaultEvent;

import
mx.controls.Alert;
import mx.managers.CursorManager;

import
mx.collections.ArrayCollection;
[
Bindable]

publicvar adhoc:ArrayCollection = new ArrayCollection();
[
Bindable]
publicvar serverString = "" ;


privatefunction initImage(event:MouseEvent):void {

if(adhoc.length > 0){
CursorManager.setBusyCursor();
}

}


privatefunction onChange():void{

if(comboBox.selectedIndex == 0){

}
else{

}
}


privatefunction onChange1():void{

if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"){
datepick.visible =
true

txt.visible =
false

}
else{
txt.visible =
true

datepick.visible =
false

}

}

privatefunction add():void{

var str:String = txt.text;
if(str.length == 0 && txt.visible == true){
Alert.show(
"Value Can Not Be Empty");
return;
}

if(combo2.selectedItem != "DATEDEPLOYED" || combo2.selectedItem != "DATEUPLOADED"){

if(txt.visible == true){
var temp:Object = new Object();
temp.fname = combo2.selectedItem;
temp.opera = combo1.selectedItem;
temp.val =
"'"+txt.text+"'";
adhoc.addItem(temp);
txt.text =
"";
}
}

var str1:String = datepick.text;
if(comboBox.selectedIndex == 1){
if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"){
if(str1.length == 0 && datepick.visible == true){
Alert.show(
"Date Cannot Be Empty");
}
else{
var temp:Object = new Object();
temp.fname = combo2.selectedItem;
temp.opera = combo1.selectedItem;
temp.val = datepick.text;
adhoc.addItem(temp);
datepick.text =
"";
}
}
}

addbutton.enabled =
false;
addopenbracket.enabled =
false;
combo2.enabled =
false;
combo1.enabled =
false;
}

privatefunction querydelete():void{

if (AdHoc.selectedIndex > 0) {
if(AdHoc.selectedIndex == (adhoc.length-1)){
adhoc[AdHoc.selectedIndex-1].cond =
"";
addopenbracket.enabled =
false;
addclosebracket.enabled =
false;
addbutton.enabled =
false;
combo2.enabled =
false;
combo1.enabled =
false;
}
combo2.selectedItem = adhoc[adhoc.length-2].fname
combo1.selectedItem = adhoc[adhoc.length-2].opera
adhoc.removeItemAt(AdHoc.selectedIndex);
// adhocdetailgridcompilance.dataProvider = null ;

// adhocdetailgrid.dataProvider = null ;


}
elseif (adhoc.length == 1) {
adhoc.removeItemAt(AdHoc.selectedIndex);
// adhocdetailgridcompilance.dataProvider = null ;

// adhocdetailgrid.dataProvider = null ;

addopenbracket.enabled =
true;
addclosebracket.enabled =
true;
addbutton.enabled =
true;
combo2.enabled =
true;
combo1.enabled =
true;
}
else{
Alert.show(
"Select The Rows To Delete");
}



}

privatefunction andSubmit():void{

foreach(var obj:Object in adhoc){
if(obj.fname == combo2.selectedItem && obj.opera == combo1.selectedItem){
if(combo2.selectedItem != "DATEDEPLOYED" || combo2.selectedItem != "DATEUPLOADED"){
if(txt.visible == true){
trace("2 equals");
var temp:Object = new Object();
obj.cond = and.label
adhoc.setItemAt(obj,adhoc.getItemIndex(obj));
}
else{
trace(obj.fname + ":" + combo2.selectedItem);
trace(obj.opera + ":" + combo1.selectedItem);
trace(obj.val + ":" + "'"+txt.text+"'");
}
}
}
elseif(obj.fname == addclosebracket.label){
if(combo2.selectedItem != "DATEDEPLOYED" || combo2.selectedItem != "DATEUPLOADED"){
if(txt.visible == true){
trace("2 equals");
var temp:Object = new Object();
obj.cond = and.label
adhoc.setItemAt(obj,adhoc.getItemIndex(obj));
}
else{
trace(obj.fname + ":" + combo2.selectedItem);
trace(obj.opera + ":" + combo1.selectedItem);
trace(obj.val + ":" + "'"+txt.text+"'");
}
}
}

if(obj.fname == combo2.selectedItem && obj.opera == combo1.selectedItem){
if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"){
if(datepick.visible == true){
trace("2 equals");
var temp:Object = new Object();
obj.cond = and.label
adhoc.setItemAt(obj,adhoc.getItemIndex(obj));
}
else{
trace(obj.fname + ":" + combo2.selectedItem);
trace(obj.opera + ":" + combo1.selectedItem);
trace(obj.val + ":" + datepick.text);
}
}
}
elseif(obj.fname == addclosebracket.label){
if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"){
if(txt.visible == true){
trace("2 equals");
var temp:Object = new Object();
obj.cond = and.label
adhoc.setItemAt(obj,adhoc.getItemIndex(obj));
}
else{
trace(obj.fname + ":" + combo2.selectedItem);
trace(obj.opera + ":" + combo1.selectedItem);
trace(obj.val + ":" + datepick.text);
}
}
}
}
addbutton.enabled =
true;
addopenbracket.enabled =
true;
combo2.enabled =
true;
combo1.enabled =
true;
}

privatefunction orSubmit():void{

foreach(var obj:Object in adhoc){
if(obj.fname == combo2.selectedItem && obj.opera == combo1.selectedItem){
if(combo2.selectedItem != "DATEDEPLOYED" || combo2.selectedItem != "DATEUPLOADED"){
if(txt.visible == true){
trace("2 equals");
var temp:Object = new Object();
obj.cond = or.label
adhoc.setItemAt(obj,adhoc.getItemIndex(obj));
}
else{
trace(obj.fname + ":" + combo2.selectedItem);
trace(obj.opera + ":" + combo1.selectedItem);
trace(obj.val + ":" + "'"+txt.text+"'");
}
}
}
elseif(obj.fname == addclosebracket.label){
if(combo2.selectedItem != "DATEDEPLOYED" || combo2.selectedItem != "DATEUPLOADED"){
if(txt.visible == true){
trace("2 equals");
var temp:Object = new Object();
obj.cond = or.label
adhoc.setItemAt(obj,adhoc.getItemIndex(obj));
}
else{
trace(obj.fname + ":" + combo2.selectedItem);
trace(obj.opera + ":" + combo1.selectedItem);
trace(obj.val + ":" + "'"+txt.text+"'");
}
}
}

if(obj.fname == combo2.selectedItem && obj.opera == combo1.selectedItem){
if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"){
if(datepick.visible == true){
trace("2 equals");
var temp:Object = new Object();
obj.cond = or.label
adhoc.setItemAt(obj,adhoc.getItemIndex(obj));
}
else{
trace(obj.fname + ":" + combo2.selectedItem);
trace(obj.opera + ":" + combo1.selectedItem);
trace(obj.val + ":" + datepick.text);
}
}
}
elseif(obj.fname == addclosebracket.label){
if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"){
if(txt.visible == true){
trace("2 equals");
var temp:Object = new Object();
obj.cond = or.label
adhoc.setItemAt(obj,adhoc.getItemIndex(obj));
}
else{
trace(obj.fname + ":" + combo2.selectedItem);
trace(obj.opera + ":" + combo1.selectedItem);
trace(obj.val + ":" + datepick.text);
}
}
}
}
addbutton.enabled =
true;
addopenbracket.enabled =
true;
combo2.enabled =
true;
combo1.enabled =
true;
}

publicfunction addOpenBracket():void{

var temp:Object = new Object();
temp.fname = addopenbracket.label
adhoc.addItem(temp);
addopenbracket.enabled =
false

addclosebracket.enabled =
true

if(adhoc.length > 1 && addopenbracket.enabled == false){
addbutton.enabled =
true

}

}

publicfunction addCloseBracket():void{

var temp:Object = new Object();
if(adhoc.length > 1){
temp.fname = addclosebracket.label
adhoc.addItem(temp);
addopenbracket.enabled =
true

addclosebracket.enabled =
false
}
if(adhoc.length > 1 && addclosebracket.enabled == false){
addbutton.enabled =
true

}
}
privatefunction dateChange(date:Date):void{

if (date == null){

}
else{
txt.text = date.getDate() +
'/' + (date.getMonth()+1).toString() + '/' +
date.getFullYear().toString() ;
}

}
publicfunction saveadhoc(event:Event):void {

var AdhocRows:String = "";
var i:int ;
var selectedType = comboBox.selectedItem;


if(adhoc.length == 0){
Alert.show(
"Enter The Query");
}
else{

for(i = 0; i < adhoc.length;i++) {
if(adhoc[i].fname != null){
AdhocRows = AdhocRows +adhoc[i].fname+
" ";
}
if(adhoc[i].opera != null){
AdhocRows = AdhocRows + adhoc[i].opera+
" ";
}
if(adhoc[i].val != null){
AdhocRows = AdhocRows + adhoc[i].val+
" ";
}
if(adhoc[i].cond != null){
AdhocRows = AdhocRows + adhoc[i].cond+
" ";
}

}
var parameters:Object = {adhocquery:AdhocRows,FlexActionType:"ADHOCQUERYSUBMIT",adhocType:selectedType};
// adhocClick.send(parameters);

}
}

privatefunction retrieve():void{

datepick.visible =
false

txt.visible =
true


}




]]>
</mx:Script>

<mx:Array id="comp">

<mx:String>TYPE</mx:String>
<mx:String>AUDITRESULT</mx:String>

<mx:String>CATEGORY</mx:String>

<mx:String>CHILDRULE</mx:String>
<mx:String>PARENTRULE</mx:String>

<mx:String>AUDITGROUP</mx:String>

<mx:String>LOCATION</mx:String>

<mx:String>VENDOR</mx:String>

<mx:String>DEVICECATEGORY</mx:String>

</mx:Array>



<mx:Array id="inven">

<mx:String>VENDOR</mx:String>

<mx:String>DEVICETYPE</mx:String>

<mx:String>SERIES</mx:String>

<mx:String>MODEL</mx:String>

<mx:String>SUP/CPU</mx:String>

<mx:String>CODEVERSION</mx:String>

<mx:String>IMAGENAME</mx:String>

<mx:String>DATEDEPLOYED</mx:String>

<mx:String>LOCATIONNAME</mx:String>

<mx:String>ADDRESS1</mx:String>

<mx:String>ADDRESS2</mx:String>

<mx:String>CITY</mx:String>

<mx:String>STATE</mx:String>

<mx:String>COUNTRY</mx:String>

<mx:String>FLOOR</mx:String>
<mx:String>CABINET</mx:String>

<mx:String>CATEGORYNAME</mx:String>

<mx:String>DEPARTMENT</mx:String>

<mx:String>CONTACTNAME</mx:String>

<mx:String>CONTACTNUMBER</mx:String>

<mx:String>VERSION</mx:String>

<mx:String>FILENAME</mx:String>

<mx:String>DATEUPLOADED</mx:String>

</mx:Array>


<mx:Accordion x="13" y="55" width="230" height="492">
<mx:Form
label="AdHoc Query Analyzer" width="100%" creationComplete="retrieve()" height="100%" color="#F2F8F9" backgroundColor="#020202">

<mx:Canvas label="Query" width="204" height="440" backgroundColor="#020202">

<mx:ComboBox x="66" y="287" width="134" id="comboBox" dataProvider="[COMPLIANCE , INVENTORY]" change="onChange()" color="#050505">
</mx:ComboBox>

<mx:ComboBox x="5" y="344" width="109.25" id="combo1" dataProvider="[=,!=,>,>=,&lt;,&lt;=,LIKE]" color="#010101"></mx:ComboBox>

<mx:TextInput x="119.25" y="344" width="77.75" id="txt" color="#050505"/>

<mx:Button x="3" y="401" label="Add" width="59" click="add()" id="addbutton" color="#FFFEFE" fillAlphas="[0.6, 0.4, 0.75, 0.65]" fillColors="[#FFFFFF, #CCCCCC, #EEEEEE, #EEEEEE]" borderColor="#B7BABC" themeColor="#009DFF"/>

<mx:Button x="66" y="401" label="Delete" width="63.25" click="querydelete()" color="#FFFEFE" fillAlphas="[0.6, 0.4, 0.75, 0.65]" fillColors="[#FFFFFF, #CCCCCC, #EEEEEE, #EEEEEE]" borderColor="#B7BABC" themeColor="#009DFF"/>

<mx:Button x="2" y="373" label="(" id="addopenbracket" click="addOpenBracket()" width="45" color="#FFFEFE" fillAlphas="[0.6, 0.4, 0.75, 0.65]" fillColors="[#FFFFFF, #CCCCCC, #EEEEEE, #EEEEEE]" borderColor="#B7BABC" themeColor="#009DFF"/>

<mx:Button x="51" y="373" label=")" id="addclosebracket" click="addCloseBracket()" width="45" color="#FFFEFE" fillAlphas="[0.6, 0.4, 0.75, 0.65]" fillColors="[#FFFFFF, #CCCCCC, #EEEEEE, #EEEEEE]" borderColor="#B7BABC" themeColor="#009DFF"/>

<mx:Button x="134.25" y="401" label="Submit" click="saveadhoc(event);initImage(event)" color="#FFFEFE" fillAlphas="[1.0, 0.69, 0.75, 0.65]" fillColors="[#77B97A, #77B97A, #EEEEEE, #EEEEEE]" borderColor="#77B97A" themeColor="#009DFF"/>


<mx:ComboBox x="66" y="317" width="134" id="combo2" change="onChange1()" dataProvider="{comp}" color="#010101">

</mx:ComboBox>

<mx:DateField x="122.25" y="344" width="74.75" initialize="dateChange((event.target).selectedDate )" id="datepick" color="#050505"/>

<mx:DataGrid x="1" y="1" width="203" height="282" id="AdHoc" dataProvider="{adhoc}" allowMultipleSelection="true" color="#020202">

<mx:columns>

<mx:DataGridColumn headerText="Name" dataField="fname" id="fnam"/>

<mx:DataGridColumn headerText="Operator" dataField="opera" id="ope"/>

<mx:DataGridColumn headerText="Value" dataField="val" id="valu"/>

<mx:DataGridColumn headerText="Condition" dataField="cond" id="condt"/>

</mx:columns>

</mx:DataGrid>

<mx:Button x="99" y="373" label="AND" width="52" click="andSubmit()" id="and" color="#FFFEFE" fillAlphas="[0.6, 0.4, 0.75, 0.65]" fillColors="[#FFFFFF, #CCCCCC, #EEEEEE, #EEEEEE]" borderColor="#B7BABC" themeColor="#009DFF"/>

<mx:Button x="154" y="373" label="OR" width="49" click="orSubmit()" id="or" color="#FFFEFE" fillAlphas="[0.6, 0.4, 0.75, 0.65]" fillColors="[#FFFFFF, #CCCCCC, #EEEEEE, #EEEEEE]" borderColor="#B7BABC" themeColor="#009DFF"/>

<mx:Label x="7" y="291" text="TYPE" width="59" fontWeight="bold"/>

<mx:Label x="5" y="319" text="DISPLAY" width="59" fontWeight="bold"/>

</mx:Canvas>

</mx:Form>

</mx:Accordion>


</mx:Application>

[code]
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieving Data Grid Cell Value Using Javascript dotnetsathya ASP.NET 1.0 and 1.1 Basics 0 October 23rd, 2008 02:00 AM
How to Get Specific Cell Value of Data Grid in C# akumarp2p C# 1 February 1st, 2007 07:17 AM
enable/disable checkbox in data grid on edit maddy137 ASP.NET 1.0 and 1.1 Professional 3 January 8th, 2007 12:28 AM
validation of one cell of a Data Grid to another Ljhopkins ASP.NET 1.0 and 1.1 Basics 1 November 5th, 2005 12:53 AM
Data Grid edit problem rajanikrishna General .NET 2 December 8th, 2004 08:34 AM



All times are GMT -4. The time now is 06:46 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.