[Users] GeoExt.grid.featureSelectionModel problem

Christian Mayer mayer at terrestris.de
Fri Nov 11 09:53:21 CET 2011


Hi Brad,

I just tried to reconstruct what you described:
What I have done:
  - I added a feature to an existing feature grid by adding this feature
to the corresponding layer -> works fine
  - Then I executed gridPanel.getSelectionModel().selectLastRow() what
selects me the last feature in my grid (the newly added feature)
  - grid.getView().ensureVisible(recno, 0, true):  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.

The solution you are looking for is:

  - grid.getView().focusRow(recno-1);


Best regards,
Chris



[1] http://docs.sencha.com/ext-js/3-4/#!/api/Ext.grid.GridView
<http://docs.sencha.com/ext-js/3-4/#%21/api/Ext.grid.GridView>

Am 11.11.2011 08:40, schrieb Brad Spencer:
> 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
> Users at geoext.org
> http://www.geoext.org/cgi-bin/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20111111/7210ea87/attachment.htm 


More information about the Users mailing list