I have seen a couple posts around somewhat similar problems but none of those
workarounds seem to address my issue. I am hoping that there is a viable
solution as i think this should be a pretty straightforward usecase. I am
trying to use the datagrid to display a source file. Each row in the grid
corresponds to a single line in the source file. Using a datagrid gives me
great control over the rendering of each line as well as an easy mechanism for
storing high level metainformation about the code constructs represented by
that row enabling very dynamic navigation through the codebase. In addition it
is easy for me to chunk and paginate through large files. All of these
benefits led me to this implementation. The one major issue that I am having
is the horizontal scrolling of the grid. I have set up the grid so that it uses
two columns, one representing the gutter of the source file and the other
representing the text. This requires the second columns to be capable of
displaying arbitrarily long lines of text (and wrapping is not a reasonable
option). Because the second column is of a arbitrary size i need to enable
horizontal scrolling on the datagrid to allow access to the information that
could spill off the edge of the screen. I have tried a few approaches to this
problem and have found no reasonable solution. If i set the width of the
datagrid to be a large size then i get the appropriate horizontal scroll bar
but no vertical on(it is pushed off the screen). If i set the maxWidth of the
data grid and increase the width of the second column i get strange behavior
where the horizontal and vertical scroll show up properly but the horizontal
scroll does not really enable navigation - the slider is half the width of the
scroll bar and when scrolled all the way to the right it causes the grid to
scroll but only a small fraction of the necessary distance.
I am incredibly frustrated right now. This is a very powerful and flexible
solution for my problem and i am thwarted by what seems to be a trivial bug. I
am scared i may have to reimplement everything i have done so far if i can not
solve this issue.
Thank you for your time
Russ
<Canvas xmlns:mx="http://www.adobe.com/2006/mxml" verticalScrollPolicy="off"
horizontalScrollPolicy="off">
<mx:Script>
<![CDATA[
import mx.events.ResizeEvent;
import mx.collections.IViewCursor;
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import mx.controls.dataGridClasses.DataGridColumn;
import mx.managers.CursorManager;
[Bindable]
private var itemAC:ArrayCollection;
public override function onCreationComplete(event:Event):void{
this.addEventListener(ResizeEvent.RESIZE, resize);
}
public var issueList:IssueList;
private function resize(event:ResizeEvent):void{
this.invalidateSize(); //causes canvas to be remeasured just
before resizeIt()
callLater(resizeIt); //this will do the resize after we get
actual size of canvas
}
private function resizeIt():void{
if(dg.measuredWidth > this.width){
dg.maxWidth = this.width;
dg.width = Number.NaN;
}
else{
//if the sum of all columns widths is less than the width of
the canvas
//then max the width to prevent deadspace
dg.width = this.width;
dg.maxWidth = Number.NaN;
}
dg.maxHeight = this.height;
}
public function resetWidth():void{
//sourceCol.width =
RenderedSourceFileVO(model.collections.get(DataCon stants.ENTITY_CURRENT_SOURCEFI
LE)).maxLength;
}
]]>
</mx:Script>
<mx

ataGrid
dataProvider="{RenderedSourceFileVO(model.collecti ons.get(DataConstants.ENTITY_C
URRENT_SOURCEFILE)).lineInfos}"
showHeaders="false"
variableRowHeight="true"
sortableColumns="false"
allowMultipleSelection="false"
mouseFocusEnabled="false"
id="dg"
dragEnabled="false"
dropEnabled="false"
dragMoveEnabled="false"
horizontalScrollPolicy="auto"
height="100%">
<mx:columns>
<mx

ataGridColumn width="40" >
<mx:itemRenderer>
<mx:Component>
<mx:Label height="5" text="{(data is TraceElementLineInfoVO ?
'':data.sourceLineNumber)}">
<mx:Script>
<![CDATA[
import com.fortify.manager.vo.TraceElementLineInfoVO;
]]>
</mx:Script>
</mx:Label>
</mx:Component>
</mx:itemRenderer>
</mx

ataGridColumn>
<mx

ataGridColumn id="sourceCol" dataField="renderedText" >
<mx:itemRenderer>
<mx:Component>
<mx:HBox verticalGap="0" width="100%" horizontalGap="0"
height="100%" initialize="init()" >
<mx:Script>
<![CDATA[
import mx.events.FlexEvent;
import com.ericfeminella.utils.QueryString;
import com.ericfeminella.utils.IQueryString;
import mx.events.ScrollEvent;
import com.fortify.manager.vo.LineInfoVO;
import com.fortify.manager.vo.TraceElementLineInfoVO;
import mx.controls.DataGrid;
import com.fortify.manager.model.FMModelLocator;
override protected function measure():void{
super.measure();
//override the two line minimum size for textarea
this.measuredHeight =15;
}
]]>
</mx:Script>
<mx:TextArea
selectable="true"
id="sourceText"
paddingTop="0"
paddingBottom="0"
borderThickness="0"
styleName="sourcePanel"
width="100%"
height="100%"
styleSheet="{FMModelLocator.getInstance().sourceSt yleSheet}"
wordWrap="false"
condenseWhite="true"
editable="false"
horizontalScrollPolicy="off"
link="outerDocument.issueList.onClickLink(event)"
doubleClick="doubleClick(event)"
text="{LineInfoVO(data).renderedText}"
/>
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx

ataGridColumn>
</mx:columns>
</mx

ataGrid>
</Canvas>