<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Brad,<br>
<br>
I just tried to reconstruct what you described:<br>
What I have done:<br>
- I added a feature to an existing feature grid by adding this
feature to the corresponding layer -> works fine<br>
- Then I executed <span class="Apple-style-span" style="color:
rgb(0, 0, 0); font-family: 'dejavu sans mono',monospace;
font-size: 11px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal; line-height: normal;
orphans: 2; text-indent: 0px; text-transform: none; white-space:
pre-wrap; widows: 2; word-spacing: 0px; background-color: rgb(255,
255, 255);">gridPanel.getSelectionModel().selectLastRow() </span>what
selects me the last feature in my grid (the newly added feature)<br>
- <tt>grid.getView().ensureVisible(recno, 0, true</tt>): I could
not detect a function ensureVisible of a Ext.grid.GridView within
the API docs, see [1]. The reason for that is the fact that
ensureVisible is a private function. You should not use this.<br>
<br>
The solution you are looking for is:<br>
<br>
<pre> - <tt>grid.getView().focusRow(recno-1);</tt></pre>
<br>
Best regards,<br>
Chris<br>
<br>
<br>
<br>
[1] <a
href="http://docs.sencha.com/ext-js/3-4/#%21/api/Ext.grid.GridView">http://docs.sencha.com/ext-js/3-4/#!/api/Ext.grid.GridView</a><br>
<br>
Am 11.11.2011 08:40, schrieb Brad Spencer:
<blockquote cite="mid:00a501cca045$43037770$c90a6650$@com.au"
type="cite">
<pre wrap="">List,
Dev environment Ext 3.4.0 and OpenLayers 2.9
I have built an app that allows a user to select a JSON/KML file from a
server-side directory list and load as a markup layer. The app successfully
display any attributes in an Ext.grid.EditorGridPanel object and I have
instigated GeoExt.grid.FeatureSelectionModel such that the user can select a
map feature and edit any of its attributes inside the grid. All is well
there; however, when the user enters a new geometry feature via an
openlayers OpenLayers.Control.DrawFeature control by digitizing a point,
line or polygon the map is updated just fine and a new row is automatically
added at the bottom of the grid with empty attribute values, as expected.
I want the user to know that they must enter attribute values by setting the
focus of the grid on the new record and making sure that the new record is
visible given it will be at the end of a scrolling grid. So what I have done
is added a ‘featuresadded’ listener of the Openlayers markup layer that
determines the end of the grid and should set the focus to the new row and
then make sure its visible. I have also made sure that
‘deferRowRender:false’ has been set on the Ext.grid.EditorGridPanel object.
The listener looks like the following:
// if the grid is present then force new created cell to be visible in grid
if(grid)
{
var recno = grid.store.data.items.length;         // this gives me the
correct newly added row number
grid.getSelectionModel().selectLastRow()         // this sets focus
to the last point in the layer on load only. Aftyer that with each add it
sets the focus on the previous point added not the current new point.
grid.getView().ensureVisible(recno, 0, true);        // this does not
work. The grid is refreshed to top of grid
}
I am not sure why this is not working and I have tried a lot of other
combinations. Can someone see something wrong or stupid with this?
Cheers, Brad....
_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@geoext.org">Users@geoext.org</a>
<a class="moz-txt-link-freetext" href="http://www.geoext.org/cgi-bin/mailman/listinfo/users">http://www.geoext.org/cgi-bin/mailman/listinfo/users</a>
</pre>
</blockquote>
</body>
</html>