Jay Roy
asked on
populating data in richtext from a For loop
hi guys
I have a question . I am getting the data from the backend as a arraycollection and trying to populate the rich text areas.
here is my flex code
<mx:VBox width="66%" styleName="responseBox">
<mx:HBox width="66%">
<mx:RichTextEditor id="questoin1" width="1050" title="this should contain the 1st question id from the above for loop" text="this should contain the 1st question name from the above for loop" maxHeight="261" creationComplete="expcoll( event)"/>
</mx:HBox>
</mx:VBox>
<mx:VBox width="66%" styleName="responseBox">
<mx:HBox width="66%">
<mx:RichTextEditor id="questoin1" width="1050" title="this should contain the 2nd question id " text="this should contain the 2nd question name " maxHeight="261" creationComplete="expcoll( event)"/>
</mx:HBox>
</mx:VBox>
....
and so on
any easy way and best way to do it ?
thanks
I have a question . I am getting the data from the backend as a arraycollection and trying to populate the rich text areas.
here is my flex code
for (var i= 0; i < screenList.length; i++){
screens = screenList[i] as ScreenDTO;
for(var j=0; j < screens.questionList; j++){
question = screens.questionList[i] as QuestionDTO;
if(question != null){
Alert.show("question id", questions.id); -- this is the question id
Alert.show("question desc", questions.description); -- this is the question name
}
} }
I have 25 such questions ids and names which i am trying to populate in the richtext areas <mx:VBox width="66%" styleName="responseBox">
<mx:HBox width="66%">
<mx:RichTextEditor id="questoin1" width="1050" title="this should contain the 1st question id from the above for loop" text="this should contain the 1st question name from the above for loop" maxHeight="261" creationComplete="expcoll(
</mx:HBox>
</mx:VBox>
<mx:VBox width="66%" styleName="responseBox">
<mx:HBox width="66%">
<mx:RichTextEditor id="questoin1" width="1050" title="this should contain the 2nd question id " text="this should contain the 2nd question name " maxHeight="261" creationComplete="expcoll(
</mx:HBox>
</mx:VBox>
....
and so on
any easy way and best way to do it ?
thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
For the data collection rendering you can simply user mx:List
<mx:List id="myList" dataProvider="{myDP}" width="220" height="200" showDataTips="true"/>
<mx:List id="myList" dataProvider="{myDP}" width="220" height="200" showDataTips="true"/>
ASKER
ok thanks but i am having difficulty understanding your comment.
where do i use <mx:List id="myList" dataProvider="{myDP}" width="220" height="200" showDataTips="true"/> ?
I am already iterating the list (in my case questionList) usng a for loop like this
for(var j=0; j < screens.questionList; j++){
question = screens.questionList[j] as QuestionDTO; //QuestionDTO has id,description
if(question != null){
Alert.show("question id", questions.id); -- this question id should be set in richtext title
Alert.show("question desc", questions.description); -- this question name should be set in richtext text
}
}
thx
where do i use <mx:List id="myList" dataProvider="{myDP}" width="220" height="200" showDataTips="true"/> ?
I am already iterating the list (in my case questionList) usng a for loop like this
for(var j=0; j < screens.questionList; j++){
question = screens.questionList[j] as QuestionDTO; //QuestionDTO has id,description
if(question != null){
Alert.show("question id", questions.id); -- this question id should be set in richtext title
Alert.show("question desc", questions.description); -- this question name should be set in richtext text
}
}
thx
>> i cant do that because i already have multiple rich text areas and in between i have non-rich text areas like text boxes.
I see.
I think using what you find
@ http://livedocs.adobe.com/flex/3/html/help.html?content=usingas_8.html
and
@ http://livedocs.adobe.com/flex/3/html/help.html?content=containers_intro_6.html
should work.
1. You should look for child components with the names "questoin1", "questoin2", "questoin3",...
(and this is possible in a loop with inside
2. Once found you can set their properties 'title' and 'text'
I see.
I think using what you find
@ http://livedocs.adobe.com/flex/3/html/help.html?content=usingas_8.html
and
@ http://livedocs.adobe.com/flex/3/html/help.html?content=containers_intro_6.html
should work.
1. You should look for child components with the names "questoin1", "questoin2", "questoin3",...
(and this is possible in a loop with inside
var nameToLookFor : String = "question" + i;
)2. Once found you can set their properties 'title' and 'text'
With any Flex control, you can have custom item renderer.
Look at "Example: Using an item renderer with a List control" at
http://livedocs.adobe.com/flex/3/html/help.html?content=cellrenderer_8.html
Look at "Example: Using an item renderer with a List control" at
http://livedocs.adobe.com/flex/3/html/help.html?content=cellrenderer_8.html
ASKER
ok...but what i had in mind is can i just set the first id/description in the list to first rich text box
the second id/description in the list to second rich text box and so on?
for(var j=0; j < screens.questionList; j++){
question = screens.questionList[j] as QuestionDTO; //QuestionDTO has id,description
if(question != null){
Alert.show("question id", questions.id); -- this question id should be set in richtext title
Alert.show("question desc", questions.description); -- this question name should be set in richtext text
}
}
1st question
<mx:VBox width="66%" styleName="responseBox">
<mx:HBox width="66%">
<mx:RichTextEditor id="questoin1" width="1050" title="screens.questionLis t[j].id" --> j=1 text="screens.questionList [j].descri ption" maxHeight="261" creationComplete="expcoll( event)"/>
</mx:HBox>
</mx:VBox>
2nd Question
<mx:VBox width="66%" styleName="responseBox">
<mx:HBox width="66%">
<mx:RichTextEditor id="questoin2" width="1050" title="screens.questionLis t[j].id" --> j=2 text="screens.questionList [j].descri ption " maxHeight="261" creationComplete="expcoll( event)"/>
</mx:HBox>
</mx:VBox>
the second id/description in the list to second rich text box and so on?
for(var j=0; j < screens.questionList; j++){
question = screens.questionList[j] as QuestionDTO; //QuestionDTO has id,description
if(question != null){
Alert.show("question id", questions.id); -- this question id should be set in richtext title
Alert.show("question desc", questions.description); -- this question name should be set in richtext text
}
}
1st question
<mx:VBox width="66%" styleName="responseBox">
<mx:HBox width="66%">
<mx:RichTextEditor id="questoin1" width="1050" title="screens.questionLis
</mx:HBox>
</mx:VBox>
2nd Question
<mx:VBox width="66%" styleName="responseBox">
<mx:HBox width="66%">
<mx:RichTextEditor id="questoin2" width="1050" title="screens.questionLis
</mx:HBox>
</mx:VBox>
1. Is your previous comment intended to me or to pravinasar? If to me: see my previous comment
2. There's no need to always repost your same code
2. There's no need to always repost your same code
ASKER
>>>Is your previous comment intended to me or to pravinasar?
both
>>>There's no need to always repost your same code
Pay a little more attention, its not same code, see my code in BOLD
1st question
<mx:VBox width="66%" styleName="responseBox">
<mx:HBox width="66%">
<mx:RichTextEditor id="questoin1" width="1050" title="screens.questionLis t[j].id" --> j=1 text="screens.questionList [j].descri ption" maxHeight="261" creationComplete="expcoll( event)"/>
</mx:HBox>
</mx:VBox>
2nd Question
<mx:VBox width="66%" styleName="responseBox">
<mx:HBox width="66%">
<mx:RichTextEditor id="questoin2" width="1050" title="screens.questionLis t[j].id" --> j=2 text="screens.questionList [j].descri ption " maxHeight="261" creationComplete="expcoll( event)"/>
</mx:HBox>
</mx:VBox>
both
>>>There's no need to always repost your same code
Pay a little more attention, its not same code, see my code in BOLD
1st question
<mx:VBox width="66%" styleName="responseBox">
<mx:HBox width="66%">
<mx:RichTextEditor id="questoin1" width="1050" title="screens.questionLis
</mx:HBox>
</mx:VBox>
2nd Question
<mx:VBox width="66%" styleName="responseBox">
<mx:HBox width="66%">
<mx:RichTextEditor id="questoin2" width="1050" title="screens.questionLis
</mx:HBox>
</mx:VBox>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanx 4 axxepting
ASKER
<mx:Repeater id="myrep" dataProvider="{myAC}">
<mx:Label id="Label1" text="This is loop #{myrep.currentItem}"/>
</mx:Repeater>
repeater repeats the Label (in my case rich text areas), i cant do that because i already have multiple rich text areas and in between i have non-rich text areas like text boxes.
i need something like
for(var j=0; j < screens.questionList; j++){
question = screens.questionList[j] as QuestionDTO;
if(question != null){
Alert.show("question id", questions.id); -- this is the question id
Alert.show("question desc", questions.description); -- this is the question name
}
}
1st question
<mx:VBox width="66%" styleName="responseBox">
<mx:HBox width="66%">
<mx:RichTextEditor id="questoin1" width="1050" title="question.id" text="question.description
</mx:HBox>
</mx:VBox>
2nd Question
<mx:VBox width="66%" styleName="responseBox">
<mx:HBox width="66%">
<mx:RichTextEditor id="questoin2" width="1050" title="question.id" text="question.description
</mx:HBox>
</mx:VBox>
thanks