EasyCFM.COM ColdFusion Forums / Flex Development / preselecting the first row in a flex datagrid

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: preselecting the first row in a flex datagrid -- page: 1 2 3 4

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

stinasius
03-15-2008 @ 8:26 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 109
Joined: Jan 2007

hi guys, how can i pre-select the first row of a flex datagrid on application load.

kicker
03-15-2008 @ 8:50 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 717
Joined: Oct 2004

create a function or put this in the application tags creationComplete attribute:

{my_dg.selectedIndex = 0}

Leave the curly brackets around it if you place it in the tag directly. Replace "my_dg" with your datagrid name.

Craig

stinasius
03-15-2008 @ 9:22 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 109
Joined: Jan 2007

hi kicker i alreay have initMeeting(); in the application tags creationComplete attribute, how can i add {my_dg.selectedIndex = 0} to it. sorry i know this quetion is kind of weak but am still new to flex.

stinasius
03-15-2008 @ 9:30 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 109
Joined: Jan 2007

sorry, just tried it out and it has worked but there is something i didnt ask that i should have probably asked at first, the datagrid is bound to certain textinputs on the doc so i wanted that the first row is preselected so that the textinputs can be populated with the data from the grid cells. this solution preselects the first row but the text inputs have no data in them.hope you can understand what am trying to say.

kicker
03-15-2008 @ 9:36 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 717
Joined: Oct 2004

You can have more than one action occur in creationComplete here is how:

creationComplete="initMeeting();my_dg.selectedIndex = 0; "

I was mistaken with the curly brackets though they are not needed.

Craig

kicker
03-15-2008 @ 9:41 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 717
Joined: Oct 2004

Do you have a on change action that is part of the datagrid tag? if not try adding the change attribute and call a function that loads what you want into your text input spaces. It should work that way since creation complete isn't called until the entire application is completed. Which means that the eventlistener for the datagrid change event should have already been established.

Craig

This message was edited by kicker on 3-15-08 @ 9:42 AM

stinasius
03-15-2008 @ 9:47 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 109
Joined: Jan 2007

i have this function'
private function selectedItemChanged():void{
                    parentDocument.next_meeting.text = meetings_dg.selectedItem.next_meeting;
                    parentDocument.topic.text = meetings_dg.selectedItem.topic;
                    parentDocument.speaker.text = meetings_dg.selectedItem.speaker;
                    parentDocument.about_presentation.text = meetings_dg.selectedItem.about_presentation;
                    parentDocument.about_speaker.text = meetings_dg.selectedItem.about_speaker;
               }
and i call it in the change attribute of the datagrid like this change="{selectedItemChanged()}"
          

stinasius
03-15-2008 @ 9:48 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 109
Joined: Jan 2007

i have this function'
private function selectedItemChanged():void{
                    parentDocument.next_meeting.text = meetings_dg.selectedItem.next_meeting;
                    parentDocument.topic.text = meetings_dg.selectedItem.topic;
                    parentDocument.speaker.text = meetings_dg.selectedItem.speaker;
                    parentDocument.about_presentation.text = meetings_dg.selectedItem.about_presentation;
                    parentDocument.about_speaker.text = meetings_dg.selectedItem.about_speaker;
               }
and i call it in the change attribute of the datagrid like this change="{selectedItemChanged()}" but still the textinputs are not being populated once the app loads.
          

kicker
03-15-2008 @ 10:04 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 717
Joined: Oct 2004

Actually you don't need to use the curly brackets. You also should have an event registered with your function since change is an event. it should look like this to properly work:

private function mychangeHandler(evt:Event):void
{
   // function tasks
}

then in your datagrid change event place this:

change="mychangeHandler(event)"

That should help get the items showing up when selected. To get the values initially to show up in your text inputs you are doing to need a few functions. I gather you are calling remotly for data, so you need to fill in your form items with data after the data has arrived.  

Craig

stinasius
03-15-2008 @ 10:14 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 109
Joined: Jan 2007

still not working, i actually need to get the values initially to show up in my text inputs since the grid is selected. what can i do?

PAGE: 1 2 3 4

Website Designed and Developed by Pablo Varando.