Hari,
  To access the dataprovider programatically you would just use a for loop 
for example.

for ( var i = 0; i < field.dataProvider.length; i++ )
        {
          if (field.dataProvider.getItemAt(i).fieldnamefromProvider == 1)
           {field.selectedItem = field.dataProvider.getItemAt(i);}
        }




Steve





----Original Message Follows----
From: "Doodi, Hari - BLS CTR" <[EMAIL PROTECTED]>
Reply-To: flexcoders@yahoogroups.com
To: "'flexcoders@yahoogroups.com'" <flexcoders@yahoogroups.com>
Subject: [flexcoders] Accessing DataProvider programatically.
Date: Fri, 3 Jun 2005 14:59:37 -0400
MIME-Version: 1.0
X-Originating-IP: 146.142.4.13
X-Sender: [EMAIL PROTECTED]
Received: from n19a.bulk.scd.yahoo.com ([66.94.237.48]) by 
MC8-F3.hotmail.com with Microsoft SMTPSVC(6.0.3790.211); Fri, 3 Jun 2005 
12:01:17 -0700
Received: from [66.218.69.4] by n19.bulk.scd.yahoo.com with NNFMP; 03 Jun 
2005 19:00:16 -0000
Received: from [66.218.66.28] by mailer4.bulk.scd.yahoo.com with NNFMP; 03 
Jun 2005 19:00:16 -0000
Received: (qmail 34462 invoked from network); 3 Jun 2005 19:00:13 -0000
Received: from unknown (66.218.66.167)  by m22.grp.scd.yahoo.com with QMQP; 
3 Jun 2005 19:00:13 -0000
Received: from unknown (HELO blsmail.bls.gov) (146.142.4.13)  by 
mta6.grp.scd.yahoo.com with SMTP; 3 Jun 2005 19:00:13 -0000
Received: by blsmail.bls.gov (Postfix, from userid 450)id 68E4AB025; Fri,  3 
Jun 2005 14:59:38 -0400 (EDT)
Received: from psbmail3.psb.bls.gov (psbmail3.psb.bls.gov [146.142.42.25])by 
blsmail.bls.gov (Postfix) with ESMTP id 44899B025for 
<flexcoders@yahoogroups.com>; Fri,  3 Jun 2005 14:59:38 -0400 (EDT)
Received: by psbmail3.psb.bls.gov with Internet Mail Service (5.5.2657.72)id 
<L53PLW02>; Fri, 3 Jun 2005 14:59:38 -0400
X-Message-Info: JGTYoYF78jGDbFbSNF53XqYFneenwJt6hnO99qCX/W4=
Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=lima; 
d=yahoogroups.com;b=V9t/RERZ9QEitUc4FQhl1UXlTEmsp2kJ3dlTJM1EyHCNTEenlupeOav1VCHZsFqvd0EydvfisuELVEJPTIgAOLpUqPkkTsJt0fJZGIB2alAXVeBIDIm2Mb5m7X5oMRj5;
X-Yahoo-Newman-Property: groups-email
X-Apparently-To: flexcoders@yahoogroups.com
X-Mailer: Internet Mail Service (5.5.2657.72)
X-eGroups-Msg-Info: 1:12:0
X-eGroups-From: "Doodi, Hari - BLS CTR" <[EMAIL PROTECTED]>
Mailing-List: list flexcoders@yahoogroups.com; contact 
[EMAIL PROTECTED]
Delivered-To: mailing list flexcoders@yahoogroups.com
List-Id: <flexcoders.yahoogroups.com>
Precedence: bulk
List-Unsubscribe: <mailto:[EMAIL PROTECTED]>
Return-Path: 
[EMAIL PROTECTED]
X-OriginalArrivalTime: 03 Jun 2005 19:01:17.0652 (UTC) 
FILETIME=[9F32B940:01C5686E]

Tracy,

             If you don't mind can you send me some code example to 
implement
dataProvider operations you explained in the earlier mail. I tried to do it
but couldn't succeed.



Here is the situation. I am getting an array of java value objects from
remote object call. I got them into a AS variable. Now I want to access
individual data elements(attributes) out of it. So far what I have done is
assign this AS var to datagrid and show to the user. Now requirements have
been changed and I have to show them in a free form text instead of grid.



What I am thinking is, from your earlier email, create a dataProvide in my
AS file and assign the result to this dataProvider and manipulate the
attributes. Please help me by sending some code example.



Thanks!
Hari

-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Tracy Spratt
Sent: Wednesday, May 25, 2005 3:09 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] creating row in datagrid at runtime



The DataGrid control is just the UI for manipulating the dataProvider.  The
dataProvider is entirely independent of the DataGrid.  You can create it,
modify its values, add and delete rows, without ever having a DataGrid
control at all.



It is the dataProvider object that you are sending to your RemoteObject, not
the DataGrid.



So to debug, programmatically create a dataProvider, and pass it to the
server.  Did it go through correctly?  If not, don't proceed until you can
make that work.

Then modify a value, programmatically, and again pass it to the server,
verify the data.

Then add a row, programmatically, ...etc.



How are you doing debugging?



Tracy



   _____

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Doodi, Hari - BLS CTR
Sent: Wednesday, May 25, 2005 2:29 PM
To: 'flexcoders@yahoogroups.com'
Subject: RE: [flexcoders] creating row in datagrid at runtime



The issue is how to do  - when I add a new row to the existing datagrid and
enter values in each cell and pass the entire datagrid with modified data
along with newly added row to java class.



If I modify existing data on datagrid and submit it, the modified data was
get to the java class (even without using editField function.)



Sorry! I did not understand what do you mean by "take the DataGrid out of
the picture entirely?" - my issue is with respect to the DataGrid. Yes, as
you said the issue is addRow , enter data and pass the datagrid to java
class. But how??

Thanks!
Hari

-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Tracy Spratt
Sent: Wednesday, May 25, 2005 2:26 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] creating row in datagrid at runtime



Well, with registered AS classes, you pass beyond my knowledge!



But back up a little.  Is the issue with the added line? What happens if you
programmatically change a value in the dataProvider and submit it? Does the
correct value get to the Java class?



Does this all work if you take the DataGrid out of the picture entirely?  If
the dataProvider alerts correctly, I doubt the issue is with the addRow.



Tracy



   _____

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Doodi, Hari - BLS CTR
Sent: Wednesday, May 25, 2005 11:35 AM
To: 'flexcoders@yahoogroups.com'
Subject: RE: [flexcoders] creating row in datagrid at runtime



Once again thanks for you concern about my issues. I tried the way asked me
to. I got the entered values alerted when you push a button but can not
access that row in my java class. I think the problem is , if you look at
the attachment in my earlier mail - also attaching now- there is registered
AS class associated with VO class in initApp() method. When we pass
dataprovider to save function as an input parameter, are we sending the
dataprovider or the mapped/register object ? How to add the newly added row
to the registered class before sending it to java class.



  Briefly what I am trying to achieve is system retrieves data from data 
base
and displays to user in datagrid format. User can modify data or/and can add
new rows to or delete rows from datagrid. When user click on save all
changes should be saved back to database. If you have any working code,
please can you post it so that I can understand it and implement technique
in my app. Once again thank you very much for your patience and help.







Thanks!
Hari

-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Tracy Spratt
Sent: Tuesday, May 24, 2005 8:31 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] creating row in datagrid at runtime



Forget the updateData function.  I have clearly been wrong when I thought
that editing a cell did not automatically update the dataProvider.  It does.



So try changing your addRow function to add a row with an item:

             function addRow()

             {

                         var oNewItem:Object = new Object();       //create
the new item object

                         oNewItem.adj_num = " ";                        
//set
its initial properties

                         oNewItem.adj_type = " ";

                         oNewItem.adj_category = " ";

                         oNewItem.adj_amt_terms_desc = " ";

                         oNewItem.adj_reporter_applied_flag = " ";

                         oNewItem.adj_sign = " ";

                         oNewItem.adj_factor = " ";

                         oNewItem.adj_order_applied = " ";



                         myDataGrid.addItem(oNewItem);

                         focusNewRow();

                         doLater(this,"focusNewRow");

             }



If you have some real, valid default values use them instead of the " "
(space).  I used a space because an empty string causes the DataGrid all
kinds of problems.



For debugging purposes, put a button and function on the page that will
alert the contents of the data provider.  That's how I determined that the
edit was updateing the dataProvider.  Something like this:]



             private function alertDp():Void

             {

                         var dp = myDataGrid.dataProvider;

                         var iRowCount:Number = dp.length;

                         var sTemp:String = "";

                         for (var i:Number=0; i<iRowCount ; i++)  {

                                     sTemp += "\n" + dp[i]. adj_num + ", " +
dp[i]. adj_type;

                         }

                         alert(sTemp)

             }//alertDp



Tracy

   _____

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Doodi, Hari - BLS CTR
Sent: Tuesday, May 24, 2005 1:31 PM
To: 'flexcoders@yahoogroups.com'
Subject: RE: [flexcoders] creating row in datagrid at runtime



Tracy,

             Here is my code. If you don't mind can you help me out in
resolving this issue. Thanks!



             <mx:DataGrid id="myDataGrid" width="100%"
dataProvider="{schedAdj_do}" textAlign="left" height="250" headerHeight="50"
editable="true" cellEdit="updateData(event)">

                 <mx:columns>

                           <mx:Array>

                             <mx:DataGridColumn headerText="#"
columnName="adj_num" width="50" editable="false" textAlign="left"/>

                             <mx:DataGridColumn headerText="Type"
columnName="adj_type" width="100" />

                             <mx:DataGridColumn headerText="Category"
columnName="adj_category" width="150" />

                             <mx:DataGridColumn headerText="Terms"
columnName="adj_amt_terms_desc" width="200" />

                             <mx:DataGridColumn headerText="{rptappl}"
columnName="adj_reporter_applied_flag" width="50" />

                             <mx:DataGridColumn headerText="Sign"
columnName="adj_sign" width="75" textAlign="center" />

                             <mx:DataGridColumn headerText="Factor"
columnName="adj_factor" width="100" textAlign="right"/>

                             <mx:DataGridColumn headerText="{ordappl}"
columnName="adj_order_applied" width="75" textAlign="left" />

                           </mx:Array>

                 </mx:columns>

               </mx:DataGrid>



             function updateData(event:Object)

             {

                         mx.controls.Alert.show("cellEdit event fired ");


                         var colName:String=
event.target.getColumnAt(event.columnIndex).columnName;

         var row:Number = event.itemIndex;

                 var dataValue = event.target.getItemAt(row)[colName];

         //mx.controls.Alert.show("event.columnIndex
:"+event.columnIndex+newline+"colName : "+colName+newline+"new value :
"+event.target.getItemAt(row)[colName]);

                         myDataGrid.dataProvider.editField(
event.columnIndex, colName, dataValue);

             }



Thanks!
Hari

-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Tracy Spratt
Sent: Monday, May 23, 2005 5:12 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] creating row in datagrid at runtime



Calling addItem() on the dataGrid is actually calling it on the dataProvider
and physically adding the line.



Now, that line is empty, the "item" would be undefined (null?), and NOTE
THIS: editing a datagrid cell does not automatically update the datagrid.
You will need to use the editCell event to call editField() to update the dp
with the entered data.  I bet your dataProvider has a line but it is empty.



Tracy



   _____

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Doodi, Hari - BLS CTR
Sent: Monday, May 23, 2005 3:25 PM
To: 'flexcoders@yahoogroups.com'
Subject: RE: [flexcoders] creating row in datagrid at runtime



Hi,

             I would like to extend the scope of this thread by asking How 
to
make this newly added row as a part of the dataprovider? What I mean is I am
able to create a new row in datagrid by using your methodology. But when I
try to access data in my POJO, I am getting nullpointer exception. That
means, I think, the newly added row to grid is not truly added to
dataprovider. Do I have to make any specific function call to make the newly
added row attach to dataprovider? If this question is already discussed,
please guide me with reference.



Thanks!
Hari

-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Tracy Spratt
Sent: Friday, May 20, 2005 4:51 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] creating row in datagrid at runtime



Here's a little mod that automatically adds the new row when you tab out of
the last cell.  The doLater reminder solved an aggravating problem I was
having!



<?xml version="1.0"?>

<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";

       xmlns="*">

<mx:Script><![CDATA[



    function checkOnNav(oEvent:Object):Void

    {

       var iItemIndex:Number;

       var iColumnIndex:Number;

       switch (oEvent.type)

       {

          case "cellFocusOut":

             iItemIndex = oEvent.itemIndex;

             iColumnIndex = oEvent.columnIndex

             if (iColumnIndex == oEvent.target.columnNames.length - 1

                      && iItemIndex == oEvent.target.length - 1 )  {
//leaving the last row, last column

                oEvent.target.addItem();

                doLater(this,"focusLastRow",[oEvent])

             }

             break;



       }//switch (oEvent.type)

    }//checkOnNav



    private function focusLastRow(oEvent:Object):Void{

       var dg:mx.controls.DataGrid = oEvent.target;

       dg.setFocus();

       dg.focusedCell = {columnIndex: 0, itemIndex:
dg.dataProvider.length-1};

    }//setFocusNextLine



]]></mx:Script>

    <mx:DataGrid id="grid" editable="true"

          cellFocusOut="checkOnNav(event)">

       <mx:dataProvider>

          <mx:Array>

             <mx:Object name="manish" colour="red" />

             <mx:Object name="abdul" colour="blue" />

          </mx:Array>

       </mx:dataProvider>

    </mx:DataGrid>



</mx:Application>



-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Manish Jethani
Sent: Friday, May 20, 2005 9:50 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] creating row in datagrid at runtime



On 5/19/05, shettyaditsathish <[EMAIL PROTECTED]> wrote:

 > i need to create a row in an existing datagrid on an event and show the

 > the 1st column of the newly created row in editable mode.



<?xml version="1.0"?>

<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";

   xmlns="*">

   <mx:Script>

     function enterNewRow():Void

     {

       grid.addItem();

       focusNewRow();

       doLater(this, "focusNewRow");

     }

     function focusNewRow():Void

     {

       grid.setFocus();

       grid.focusedCell = {columnIndex: 0, itemIndex:

grid.dataProvider.length-1};

     }

   </mx:Script>

   <mx:DataGrid id="grid" editable="true">

     <mx:dataProvider>

       <mx:Array>

         <mx:Object name="manish" colour="red" />

         <mx:Object name="abdul" colour="blue" />

       </mx:Array>

     </mx:dataProvider>

   </mx:DataGrid>

   <mx:Button label="Enter New Row" click="enterNewRow()" />

</mx:Application>



Note:



  1.  grid.addItem() will add a blank row

  2.  call focusNewRow() in the next frame using doLater()







Yahoo! Groups Links



     http://groups.yahoo.com/group/flexcoders/



     [EMAIL PROTECTED]



     http://docs.yahoo.com/info/terms/



















   _____

Yahoo! Groups Links

*         To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<http://groups.yahoo.com/group/flexcoders/>


*         To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>


*         Your use of Yahoo! Groups is subject to the Yahoo! Terms of
<http://docs.yahoo.com/info/terms/>  Service.




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to