<!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>
What I detected is the fact that you determine the size of your
records with<br>
<br>
<pre>var recno = grid.store.data.items.length; </pre>
<br>
you should use<br>
<br>
<pre>var recno = grid.getStore().getCount();
</pre>
I am not sure this has any effect but maybe you could try this.<br>
<br>
But your information "<i>I get the feeling its just setting to the
last record before it actually gets included in the grid?</i>"
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.<br>
<br>
Best regards,<br>
Christian<br>
<br>
<br>
[1] <a
href="http://docs.sencha.com/ext-js/3-4/#%21/api/Ext.data.Store-event-add">http://docs.sencha.com/ext-js/3-4/#!/api/Ext.data.Store-event-add</a><br>
<br>
<br>
Am 11.11.2011 14:11, schrieb Brad Spencer:
<blockquote cite="mid:00b501cca073$6aede300$40c9a900$@com.au"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<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]-->
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size: 11pt; font-family:
"Calibri","sans-serif"; color: rgb(31,
73, 125);">Hi Chris,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family:
"Calibri","sans-serif"; color: rgb(31,
73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family:
"Calibri","sans-serif"; color: rgb(54,
95, 145);">Thanks for advising about the </span><tt><span
style="font-size: 10pt; color: rgb(54, 95, 145);">ensureVisible
</span></tt><tt><span style="font-size: 11pt; font-family:
"Calibri","sans-serif"; color: rgb(54,
95, 145);">issue.<o:p></o:p></span></tt></p>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
font-family: "Calibri","sans-serif";
color: rgb(54, 95, 145);"><o:p> </o:p></span></tt></p>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
font-family: "Calibri","sans-serif";
color: rgb(54, 95, 145);">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: 11pt;
font-family: "Calibri","sans-serif";
color: rgb(54, 95, 145);"><o:p> </o:p></span></tt></p>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
font-family: "Calibri","sans-serif";
color: rgb(54, 95, 145);">Also, there is no difference if
I leave the </span></tt><tt><span style="font-size: 10pt;
color: rgb(54, 95, 145);">grid.getView().focusRow(recno-1);</span></tt><tt><span
style="font-size: 10pt;"> </span></tt><tt><span
style="font-size: 11pt; font-family:
"Calibri","sans-serif"; color: rgb(54,
95, 145);">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: 11pt;
font-family: "Calibri","sans-serif";
color: rgb(54, 95, 145);"><o:p> </o:p></span></tt></p>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
font-family: "Calibri","sans-serif";
color: rgb(54, 95, 145);">Thanks for the help on this
frustrating issue.<o:p></o:p></span></tt></p>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
font-family: "Calibri","sans-serif";
color: rgb(54, 95, 145);"><o:p> </o:p></span></tt></p>
<p class="MsoNormal"><tt><span style="font-size: 11pt;
font-family: "Calibri","sans-serif";
color: rgb(54, 95, 145);">Cheers, brad....</span></tt><span
style="font-size: 11pt; font-family:
"Calibri","sans-serif"; color: rgb(54,
95, 145);"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family:
"Calibri","sans-serif"; color: rgb(31,
73, 125);"><o:p> </o:p></span></p>
<div>
<div style="border-right: medium none; border-width: 1pt
medium medium; border-style: solid none none; border-color:
rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color;
padding: 3pt 0cm 0cm;">
<p class="MsoNormal"><b><span style="font-size: 10pt;
font-family:
"Tahoma","sans-serif"; color:
windowtext;" lang="EN-US">From:</span></b><span
style="font-size: 10pt; font-family:
"Tahoma","sans-serif"; color:
windowtext;" lang="EN-US"> <a class="moz-txt-link-abbreviated" href="mailto:users-bounces@geoext.org">users-bounces@geoext.org</a>
[<a class="moz-txt-link-freetext" href="mailto:users-bounces@geoext.org">mailto:users-bounces@geoext.org</a>] <b>On Behalf Of </b>Christian
Mayer<br>
<b>Sent:</b> Friday, 11 November 2011 7:53 PM<br>
<b>To:</b> <a class="moz-txt-link-abbreviated" href="mailto:users@geoext.org">users@geoext.org</a><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: 12pt;">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: 10pt;">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 moz-do-not-send="true"
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 moz-do-not-send="true" href="mailto:Users@geoext.org">Users@geoext.org</a><o:p></o:p></pre>
<pre><a moz-do-not-send="true" 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>
</blockquote>
</body>
</html>