3.2.0

Adding new rows of XML data to a grid and Firefox

I need to add new rows to an already instantiated XML grid.

In order to do this I have a function that adds a record to the raw XML text.

The following function does exactly what I want it to in IE, but Firefox has a problem. As I add rows, they scroll up and out of view. Although the vertical scrollbar remains disabled, I can scroll them back down with the arrow keys, but as soon as I link on them they scroll back up again.

What's going on here?

Here is my function :

this.addRow = function(header, record, footer)
{ var count;

count = this.table.getCount() + 1;

this.sizeGrid(count);
this.table.setXML(XmlAppend(this.table.getXML(), header, record, footer));
this.grid.addRow(count - 1);
} // addRow()
John Naker
April 29,
Stepping through the code.. It looks like the getContentHeight("center") method does not reflect any changes that should result from calling the setControlSize() method.

Is this a bug?


onCurrentRowChanged: function(i) {
var current = this.getCurrentRow();
var scroll = this.getScrollProperty("top");
var height = this.getRowProperty("height");
var top = (this.getRowPosition(current) - this.getRowOffset()) * height;
var bottom = top + height;
var max = this.getContentHeight("center"); /* old content height is returned here */
if (!max) {
return
}
if (top < scroll) {
this.setScrollTop(top)
}
if (max + scroll < bottom) {
this.setScrollTop(bottom - max)
}
if (AW.ie && this.element()) {
var h = this.element().offsetHeight
}
},
John
April 29,
Check if adding this.setRowCount(count) after this.grid.addRow(count-1); solves the issue.

But... also.. shouldn't a js function allows a max of 3 parameters?

this.table.setXML(XmlAppend(this.table.getXML(), header, record, footer));

If need to add more than one row this will fail as this.table.getCount() remains the same .
( unless update and request the XML on each row addition)
HTH
Carlos
April 29,
I experimented with adding the setRowCount() call, but this did not help, the underlaying getContentHeight("center") call continued to return a value based upon the initial control size even though I expand the height as I add new rows (up to a limit) with setControlSize().

Debuging under IE, I noticed that the getContentHeight() method continues to "fail" to reflect the new setControlSize() call. It is curious that IE recovers from this somehow. I have yet to take the time to figuer out why.

I have added a little hack to my aw.js script for the onCurrentRowChanged method as follows :

onCurrentRowChanged: function(i) {
var current = this.getCurrentRow();
var scroll = this.getScrollProperty("top");
var height = this.getRowProperty("height");
var rowPos = this.getRowPosition(current);
var rowOff = this.getRowOffset();
var top = (this.getRowPosition(current) - this.getRowOffset()) * height;
var bottom = top + height;
if ( AW.ie )
var max = this.getContentHeight("center");
else
{ var max = this.getStyle("height");
max = max.substr(0, max.length - 2) - this.getHeaderHeight() /*- this.getFooterHeight()*/;
}
if (!max) {
return
}
if (top < scroll) {
this.setScrollTop(top)
}
if (max + scroll < bottom) {
this.setScrollTop(bottom - max)
}
if (AW.ie && this.element()) {
var h = this.element().offsetHeight
}
},

For Firefox (non IE), instead of calling getContentHeight(), I call getStyle('height") and subtract out the header height.

(Note: The reason for the additional header and footer params in my XmlAppend() function is only for when the XML text is completely empty. Normally only the additional record next is needed.)
John
April 29,
I have the impression that Firefox is more attached to the XML datasource than IE (i.e. can't focused on a row with undefined data source or with invalid rowCount).

I saw some examples using an array to solve it, something like:
var data = [[1,2,3,4,5]];
obj.setCellData(function(c,r){ return r>table.getCount()-1 ? data[0]:this.getCelldata(c,r) })

Also remember a few similar issues ( on past versions) that uses a much simple adjustScrollHeight and adjustScrollBars commands.
(but not sure if valid for your case)
HTH
Carlos
April 30,

This topic is archived.

See also:


Back to support forum