I have solved the problem using search inside of the item renderer.
Something like this, simplified:

<?xml version="1.0" encoding="utf-8"?>
<s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009";
  xmlns:s="library://ns.adobe.com/flex/spark"
  xmlns:mx="library://ns.adobe.com/flex/mx"
  xmlns:gridEditorClasses="spark.components.gridEditorClasses.*"
  >
 <fx:Script>
<![CDATA[
override public function set data(value:Object):void
{
super.data = value;
if (data)
{
Question.text = data[column.dataField];
}
}
override public function prepare(hasBeenRecycled:Boolean):void
{
super.prepare(hasBeenRecycled);
if (data)
{
if (column.dataField == "QuestionText")
{
var _textTosearch:String = (column.grid.dataGrid as
ApplicantFormQuestionDataGrid).textToSearch;
var _textInstanceIndex:int = (column.grid.dataGrid as
ApplicantFormQuestionDataGrid).textInstanceIndex;
if (_textTosearch && _textTosearch != "")
{
var _startSelection:int = Question.text.search(_textTosearch);
var _endSelection:int = _startSelection + _textTosearch.length;
Question.selectRange(_startSelection, _endSelection);
if (_startSelection != -1)
{
column.grid.dataGrid.ensureCellIsVisible(_textInstanceIndex);

if (rowIndex == _textInstanceIndex)
{
Question.setStyle("unfocusedTextSelectionColor", "#FFD700");
}
else
Question.setStyle("unfocusedTextSelectionColor", "#808080");
}
}
Question.width = column.width;
mainGroup.width = column.width;
}
}
}
]]>
</fx:Script>
 <!--- The renderer's visual component. -->
<s:VGroup width="100%" gap="0" id="mainGroup">
<s:RichEditableText id="Question" verticalAlign="top" paddingTop="10"
paddingBottom="10" width="100%"
editable="false" unfocusedTextSelectionColor="gray"
focusedTextSelectionColor="#FFD700"
fontSize="{column.grid.dataGrid.getStyle('fontSize')}" paddingLeft="10"
selectionHighlighting="always"/>
</s:VGroup>
</s:GridItemRenderer>

This renderer does two things. It highlights text instances in gray color
and it allows a user to navigate thru the instances highlighting it in
gold. everything works fine. But here is another problem. If I try to
scroll datagrid by clicking on down error it's not going anywhere because
of column.grid.dataGrid.ensureCellIsVisible(_textInstanceIndex);
How could I solve this problem?

Thanks

Reply via email to