Hi Brad, What I detected is the fact that you determine the size of your records with
var recno = grid.store.data.items.length; you should use var recno = grid.getStore().getCount(); I am not sure this has any effect but maybe you could try this. But your information "/I get the feeling its just setting to the last record before it actually gets included in the grid?/" maybe is the right approach. You can ensure that the feature has been added to the store by binding to the "add-event" of the store (see [1]) and try to perform your code that focus the last row within the listener function. Best regards, Christian [1] http://docs.sencha.com/ext-js/3-4/#!/api/Ext.data.Store-event-add <http://docs.sencha.com/ext-js/3-4/#%21/api/Ext.data.Store-event-add> Am 11.11.2011 14:11, schrieb Brad Spencer: > > Hi Chris, > > > > Thanks for advising about the ensureVisible issue. > > > > I tried your suggestion again as I had already tried that with no > success -- still no success. It always seems to set the row focus on > the previous-last-point added not the last-point-added and does not > set the last record in view either. > > > > Also, there is no difference if I leave the > grid.getView().focusRow(recno-1);off all together. I get the feeling > its just setting to the last record before it actually gets included > in the grid? > > > > Thanks for the help on this frustrating issue. > > > > Cheers, brad.... > > > > *From:*users-boun...@geoext.org [mailto:users-boun...@geoext.org] *On > Behalf Of *Christian Mayer > *Sent:* Friday, 11 November 2011 7:53 PM > *To:* users@geoext.org > *Subject:* Re: [Users] GeoExt.grid.featureSelectionModel problem > > > > 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@geoext.org <mailto:Users@geoext.org> > http://www.geoext.org/cgi-bin/mailman/listinfo/users
_______________________________________________ Users mailing list Users@geoext.org http://www.geoext.org/cgi-bin/mailman/listinfo/users