[Users] GeoExt.grid.featureSelectionModel problem

Brad Spencer brad at numaps.com.au
Fri Nov 11 08:40:56 CET 2011


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....





More information about the Users mailing list