The problem was in the custom CellRender that I made, an adaptation of the "phil flash" cell render.
I update a midnight version fixed, before you can see it.
Note: always check for the item != undefined in the setValue method of your cell render class.
These ares the two cell renders that i use.
/**
*
* @Programmer: luchyx for riaevolution.com
* @Mail: [EMAIL PROTECTED]
* @Version: 1.0
* @Date: Sun Apr 23 02:54:36 2006
* @Description: Html cell render for datagrid
**/
import mx.core.UIComponent;
class HtmlCellRenderer extends UIComponent
{
var htmlComponent : TextField;
var owner;
// The row that contains this cell
var listOwner : MovieClip;
// the reference we receive to the list
var getCellIndex : Function;
// the function we receive from the list
var getDataLabel : Function;
// the function we receive from the list
var previousLabel : String = null;
// for optimization
function HtmlCellRenderer ()
{
}
function createChildren (Void) : Void
{
if (htmlComponent == undefined)
{
createLabel ("htmlComponent", 1);
}
htmlComponent.html = true;
htmlComponent.border = false;
htmlComponent.multiline = true;
htmlComponent.wordWrap = true;
htmlComponent.selectable = false;
htmlComponent.background = "">
size ();
}
// note that setSize is implemented by UIComponent and calls size(), after setting
// __width and __height
function size (Void) : Void
{
htmlComponent.setSize (__width - 2, __height - 2);
}
function setValue (str : String, item : Object, sel : Boolean) : Void
{
// check for undefinede here
if (item == undefined)
{
// Special case for headerRenderer
htmlComponent.htmlText = str;
previousLabel = null;
return;
}
var columnIndex = this ["columnIndex"];
// private property (no access function)
var columnName = getDataLabel ();
var htmlFunction : Function = listOwner.getColumnAt (columnIndex).htmlFunction;
if (htmlFunction != undefined)
{
var label = htmlFunction (item, columnName);
if (label != undefined)
{
// Important pour optimisation
// Empe un flip-flop des images
if (label != previousLabel)
{
htmlComponent.htmlText = previousLabel = label;
}
}
else
{
htmlComponent.htmlText = "";
}
}
else
{
htmlComponent.htmlText = str;
}
}
function getPreferredHeight (Void) : Number
{
if (owner == undefined) return 18;
return owner.__height - 2;
}
//function getPreferredWidth :: only really necessary for menu
}
*
* @Programmer: luchyx for riaevolution.com
* @Mail: [EMAIL PROTECTED]
* @Version: 1.0
* @Date: Sun Apr 23 02:54:36 2006
* @Description: Html cell render for datagrid
**/
import mx.core.UIComponent;
class HtmlCellRenderer extends UIComponent
{
var htmlComponent : TextField;
var owner;
// The row that contains this cell
var listOwner : MovieClip;
// the reference we receive to the list
var getCellIndex : Function;
// the function we receive from the list
var getDataLabel : Function;
// the function we receive from the list
var previousLabel : String = null;
// for optimization
function HtmlCellRenderer ()
{
}
function createChildren (Void) : Void
{
if (htmlComponent == undefined)
{
createLabel ("htmlComponent", 1);
}
htmlComponent.html = true;
htmlComponent.border = false;
htmlComponent.multiline = true;
htmlComponent.wordWrap = true;
htmlComponent.selectable = false;
htmlComponent.background = "">
size ();
}
// note that setSize is implemented by UIComponent and calls size(), after setting
// __width and __height
function size (Void) : Void
{
htmlComponent.setSize (__width - 2, __height - 2);
}
function setValue (str : String, item : Object, sel : Boolean) : Void
{
// check for undefinede here
if (item == undefined)
{
// Special case for headerRenderer
htmlComponent.htmlText = str;
previousLabel = null;
return;
}
var columnIndex = this ["columnIndex"];
// private property (no access function)
var columnName = getDataLabel ();
var htmlFunction : Function = listOwner.getColumnAt (columnIndex).htmlFunction;
if (htmlFunction != undefined)
{
var label = htmlFunction (item, columnName);
if (label != undefined)
{
// Important pour optimisation
// Empe un flip-flop des images
if (label != previousLabel)
{
htmlComponent.htmlText = previousLabel = label;
}
}
else
{
htmlComponent.htmlText = "";
}
}
else
{
htmlComponent.htmlText = str;
}
}
function getPreferredHeight (Void) : Number
{
if (owner == undefined) return 18;
return owner.__height - 2;
}
//function getPreferredWidth :: only really necessary for menu
}
Support HTML.
And with this, you can attach an icon from the library.
/**
* @class IconCellRenderer
* @tooltip provide a visual style for the combo box.
* @author [EMAIL PROTECTED]
* @version 1.0
*/
import mx.core.UIComponent
class IconCellRenderer extends UIComponent
{
var icon_mc : MovieClip;
var owner;
// The row that contains this cell
var dropdown;
// the List/grid/tree that contains this cell
var getCellIndex : Function;
// the function we receive from the list
var getDataLabel : Function;
// the function we receive from the list
private var startDepth : Number = 1;
private var flag : MovieClip;
var firstSizeCompleted : Boolean;
var icon_tool : MovieClip; // an icon that identify the component
var prev_icon : MovieClip;
// for mysterious initialization
function IconCellRenderer ()
{
//unload the default icon
icon_tool._visible = false;
icon_tool.swapDepths (999);
icon_tool.unloadMovie ();
icon_tool.removeMovieClip ();
}
function createChildren (Void) : Void
{
firstSizeCompleted = false;
// The createLabel method is a useful method of UIObject and a handy
// way to make labels in components.
if (this.flag == undefined)
{
var c = flag = this.createEmptyMovieClip ("flag", this.startDepth);
}
// Links the style of the label to the style of the grid
}
function size (Void) : Void
{
var w = __width;
var h = __height;
if (icon_mc != undefined)
{
icon_mc._x = (w - icon_mc._width) / 2;
// Mysterious initialisation
if ( ! firstSizeCompleted)
{
icon_mc._y = 0;
}
firstSizeCompleted = true;
}
}
function setValue (str : String, item : Object, sel : Boolean) : Void
{
//we are on an empty cell, so remove the icon
if (item == undefined)
{
this.prev_icon.removeMovieClip ();
delete this.prev_icon;
return;
}
var w = __width;
var h = this._parent._height;
if ( ! this.firstSizeCompleted)
{
var recent_flag = this.flag.attachMovie (str, str + "_" + this.startDepth , this.startDepth ,
{
_x : 2,
_y : 2
});
var dy = h / 2 - recent_flag._height / 2;
var dx = 5;
recent_flag._y = dy;
recent_flag._x = dx;
this.prev_icon = recent_flag;
}
}
* @class IconCellRenderer
* @tooltip provide a visual style for the combo box.
* @author [EMAIL PROTECTED]
* @version 1.0
*/
import mx.core.UIComponent
class IconCellRenderer extends UIComponent
{
var icon_mc : MovieClip;
var owner;
// The row that contains this cell
var dropdown;
// the List/grid/tree that contains this cell
var getCellIndex : Function;
// the function we receive from the list
var getDataLabel : Function;
// the function we receive from the list
private var startDepth : Number = 1;
private var flag : MovieClip;
var firstSizeCompleted : Boolean;
var icon_tool : MovieClip; // an icon that identify the component
var prev_icon : MovieClip;
// for mysterious initialization
function IconCellRenderer ()
{
//unload the default icon
icon_tool._visible = false;
icon_tool.swapDepths (999);
icon_tool.unloadMovie ();
icon_tool.removeMovieClip ();
}
function createChildren (Void) : Void
{
firstSizeCompleted = false;
// The createLabel method is a useful method of UIObject and a handy
// way to make labels in components.
if (this.flag == undefined)
{
var c = flag = this.createEmptyMovieClip ("flag", this.startDepth);
}
// Links the style of the label to the style of the grid
}
function size (Void) : Void
{
var w = __width;
var h = __height;
if (icon_mc != undefined)
{
icon_mc._x = (w - icon_mc._width) / 2;
// Mysterious initialisation
if ( ! firstSizeCompleted)
{
icon_mc._y = 0;
}
firstSizeCompleted = true;
}
}
function setValue (str : String, item : Object, sel : Boolean) : Void
{
//we are on an empty cell, so remove the icon
if (item == undefined)
{
this.prev_icon.removeMovieClip ();
delete this.prev_icon;
return;
}
var w = __width;
var h = this._parent._height;
if ( ! this.firstSizeCompleted)
{
var recent_flag = this.flag.attachMovie (str, str + "_" + this.startDepth , this.startDepth ,
{
_x : 2,
_y : 2
});
var dy = h / 2 - recent_flag._height / 2;
var dx = 5;
recent_flag._y = dy;
recent_flag._x = dx;
this.prev_icon = recent_flag;
}
}
}
It´s a tiny r.i.a created with Mtasc and Flasc.
Maybe I´ll post it to the OSFLASH show case.
Thanks for your time. ;)
On 4/23/06,
Andrew Eatherington <[EMAIL PROTECTED]> wrote:
Hi,I'm not getting anything when I click on the expand button even when I scroll to the bottom. The component just turns white - although I am sure that it just not rendering. FP8 MacOSX.I can understand that the problem you have is correct and not really a bug but a feature of the component. You might try:myDGrid.vPosition = 0;Property; sets the topmost visible item of the list. If you set this property to an index number that doesn't exist, the list scrolls to the nearest index. The default value is 0.Hope this helps,AndyOn 23 Apr 2006, at 03:25, l u c h y x wrote:I´m developing a tiny r.i.a with Mtasc, FLASC.
I´m experimenting this strange behaviour with mx.controls.DataGrid component.
This is the live example:
http://www.riaevolution.com/applications/repsol/assets/expandingpod.swf
To reproduce the bug-problem:
In "collapsed" state scroll the grid to the bottom, then click the "expand" button.
(.. wait for animation.., the grid is not animated, only resized with setSize(400,300) )
You will see only two items in the grid, and you need scroll it to view all items.
If you scroll the grid to the top the expanded or collapsed animation don´t has problems
Does anybody has a solution for it?
Thanks in advance
--
l u c h y x
r i a e v o l u t i o n ®
[EMAIL PROTECTED]
http://www.riaevolution.com
Phone: +54 (11) 4931-7006_______________________________________________osflash mailing list
_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org
--
l u c h y x
r i a e v o l u t i o n ®
[EMAIL PROTECTED]
http://www.riaevolution.com
Phone: +54 (11) 4931-7006
_______________________________________________ osflash mailing list [email protected] http://osflash.org/mailman/listinfo/osflash_osflash.org
