<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
        {font-family:"DejaVu Sans Mono";
        panose-1:2 11 6 9 3 8 4 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
tt
        {mso-style-priority:99;
        font-family:"Courier New";}
span.apple-style-span
        {mso-style-name:apple-style-span;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body bgcolor=white lang=EN-AU link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hi Chris,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#365F91'>Thanks for advising about the </span><tt><span style='font-size:10.0pt;color:#365F91'>ensureVisible </span></tt><tt><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#365F91'>issue.<o:p></o:p></span></tt></p><p class=MsoNormal><tt><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#365F91'><o:p> </o:p></span></tt></p><p class=MsoNormal><tt><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#365F91'>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. <o:p></o:p></span></tt></p><p class=MsoNormal><tt><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#365F91'><o:p> </o:p></span></tt></p><p class=MsoNormal><tt><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#365F91'>Also, there is no difference if I leave the </span></tt><tt><span style='font-size:10.0pt;color:#365F91'>grid.getView().focusRow(recno-1);</span></tt><tt><span style='font-size:10.0pt'> </span></tt><tt><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#365F91'>off all together. I get the feeling its just setting to the last record before it actually gets included in the grid?<o:p></o:p></span></tt></p><p class=MsoNormal><tt><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#365F91'><o:p> </o:p></span></tt></p><p class=MsoNormal><tt><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#365F91'>Thanks for the help on this frustrating issue.<o:p></o:p></span></tt></p><p class=MsoNormal><tt><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#365F91'><o:p> </o:p></span></tt></p><p class=MsoNormal><tt><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#365F91'>Cheers, brad....</span></tt><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#365F91'><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext'> users-bounces@geoext.org [mailto:users-bounces@geoext.org] <b>On Behalf Of </b>Christian Mayer<br><b>Sent:</b> Friday, 11 November 2011 7:53 PM<br><b>To:</b> users@geoext.org<br><b>Subject:</b> Re: [Users] GeoExt.grid.featureSelectionModel problem<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>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><span style='font-size:8.5pt;font-family:"DejaVu Sans Mono"'>gridPanel.getSelectionModel().selectLastRow() </span></span>what selects me the last feature in my grid (the newly added feature)<br> - <tt><span style='font-size:10.0pt'>grid.getView().ensureVisible(recno, 0, true</span></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:<o:p></o:p></p><pre> - <tt>grid.getView().focusRow(recno-1);</tt><o:p></o:p></pre><p class=MsoNormal><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: <o:p></o:p></p><pre>List,<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>Dev environment Ext 3.4.0 and OpenLayers 2.9<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>I have built an app that allows a user to select a JSON/KML file from a<o:p></o:p></pre><pre>server-side directory list and load as a markup layer. The app successfully<o:p></o:p></pre><pre>display any attributes in an Ext.grid.EditorGridPanel object and I have<o:p></o:p></pre><pre>instigated GeoExt.grid.FeatureSelectionModel such that the user can select a<o:p></o:p></pre><pre>map feature and edit any of its attributes inside the grid. All is well<o:p></o:p></pre><pre>there; however, when the user enters a new geometry feature via an<o:p></o:p></pre><pre>openlayers OpenLayers.Control.DrawFeature control by digitizing a point,<o:p></o:p></pre><pre>line or polygon the map is updated just fine and a new row is automatically<o:p></o:p></pre><pre>added at the bottom of the grid with empty attribute values, as expected.<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>I want the user to know that they must enter attribute values by setting the<o:p></o:p></pre><pre>focus of the grid on the new record and making sure that the new record is<o:p></o:p></pre><pre>visible given it will be at the end of a scrolling grid. So what I have done<o:p></o:p></pre><pre>is added a ‘featuresadded’ listener of the Openlayers markup layer that<o:p></o:p></pre><pre>determines the end of the grid and should set the focus to the new row and<o:p></o:p></pre><pre>then make sure its visible. I have also made sure that<o:p></o:p></pre><pre>‘deferRowRender:false’ has been set on the Ext.grid.EditorGridPanel object.<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>The listener looks like the following:<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>// if the grid is present then force new created cell to be visible in grid<o:p></o:p></pre><pre>if(grid)<o:p></o:p></pre><pre>{<o:p></o:p></pre><pre> var recno = grid.store.data.items.length; // this gives me the<o:p></o:p></pre><pre>correct newly added row number <o:p></o:p></pre><pre> grid.getSelectionModel().selectLastRow() // this sets focus<o:p></o:p></pre><pre>to the last point in the layer on load only. Aftyer that with each add it<o:p></o:p></pre><pre>sets the focus on the previous point added not the current new point.<o:p></o:p></pre><pre> grid.getView().ensureVisible(recno, 0, true); // this does not<o:p></o:p></pre><pre>work. The grid is refreshed to top of grid <o:p></o:p></pre><pre>}<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>I am not sure why this is not working and I have tried a lot of other<o:p></o:p></pre><pre>combinations. Can someone see something wrong or stupid with this?<o:p></o:p></pre><pre><o:p> </o:p></pre><pre><o:p> </o:p></pre><pre>Cheers, Brad....<o:p></o:p></pre><pre><o:p> </o:p></pre><pre><o:p> </o:p></pre><pre><o:p> </o:p></pre><pre>_______________________________________________<o:p></o:p></pre><pre>Users mailing list<o:p></o:p></pre><pre><a href="mailto:Users@geoext.org">Users@geoext.org</a><o:p></o:p></pre><pre><a href="http://www.geoext.org/cgi-bin/mailman/listinfo/users">http://www.geoext.org/cgi-bin/mailman/listinfo/users</a><o:p></o:p></pre></div></body></html>