PDA

View Full Version : [CLOSED] I want focus cell of column when I press keydown or Enter .



cottimucin
Dec 07, 2014, 11:57 AM
We use ext.net 2.5.3

I want focus cell of column when I press keydown or Enter .


I have a editable grid.

the user enter the column12 , then press the enter or keydown.

we want the next row cell active . how can I do this?





<script type="text/javascript">

var myOnEditorKey = function (field, e) {
alert('girdi');
var k = e.getKey(), newCell, g = this.grid, last = g.lastEdit, ed = g.activeEditor, shift = e.shiftKey, ae, last, r, c;

if (k == e.TAB) {
e.stopEvent();
if (shift) {
newCell = g.walkCells(ed.row, ed.col - 1, -1, this.acceptsNav, this);
} else {
newCell = g.walkCells(ed.row, ed.col + 1, 1, this.acceptsNav, this);
}
} else if (k == e.ENTER) {
e.stopEvent();
if (shift) {
newCell = g.walkCells(last.row, last.col - 1, -1, this.acceptsNav, this);
} else {
newCell = g.walkCells(last.row, last.col + 1, 1, this.acceptsNav, this);
}
}

if (newCell) {
r = newCell[0];
c = newCell[1];
this.onEditorSelect(r, last.row);
if (g.isEditor && g.editing) {
ae = g.activeEditor;
if (ae && ae.field.triggerBlur) {
ae.field.triggerBlur();
}
}
g.startEditing(r, c);
}
}


</script>



<ext:GridPanel ID="GridPanel2" runat="server" StoreID="Store2" StripeRows="true"
TrackMouseOver="true" SelectionMemory="false" ButtonAlign="Center" ForceFit="true"
Cls="x-grid-custom_Blue2" TitleAlign="Center" Hidden="true" Layout="FitLayout">


<BottomBar>
<ext:Toolbar>
<Items>
<ext:Label ID="Label9" runat="server" Html="<span style='color:Red;'>Sarı renkteki satırlar devam zorunluluğu olmayan ?ğrencileri ifade etmektedir.</span>" ></ext:Label>
</Items>
</ext:Toolbar>

</BottomBar>

<CustomConfig>
<ext:ConfigItem Name="EnableColumnHide" Value="false" Mode="Raw" />
</CustomConfig>
<ColumnModel ID="ColumnModel2" runat="server" SortAscText="Artan sırada sırala" SortDescText="Azalan sırada sırala">
<Columns>
<ext:Column ID="Column7" runat="server" Align="left" DataIndex="OGRENCINUMARASI"
Header="?ğrenci No" Sortable="true" Width="100" />

<ext:Column ID="Column77" runat="server" Align="left" DataIndex="ADISOYADI" Header="Adı Soyadı"
Sortable="true" Flex="1" />

<ext:CheckColumn ID="CheckColumn1" runat="server" Align="center" Text="Dsz" DataIndex="DSZ" StopSelection="false" Editable="true" Width="35" Sortable="false" >
<Listeners>
<BeforeCheckChange Handler="return record.data.DEVAM !== 1;" />
</Listeners>
</ext:CheckColumn>


<ext:Column ID="Column12" runat="server" Align="Center" DataIndex="VIZE1" Header="Vize1"
Sortable="true" Width="50" >
<Editor>
<ext:NumberField ID="V1" runat="server" SelectOnFocus="true" MinValue="0"
MaxValue="100" AllowDecimals="false" HideTrigger="true" DisabledCls="my-item-disabled"/>
</Editor>
</ext:Column>

<ext:Column ID="Column15" runat="server" Align="Center" DataIndex="VIZE2" Header="Vize2"
Sortable="true" Width="50">
<Editor>
<ext:NumberField ID="V2" runat="server" SelectOnFocus="true" MinValue="0"
MaxValue="100" AllowDecimals="false" HideTrigger="true" />
</Editor>
</ext:Column>
<ext:Column ID="Column16" runat="server" Align="Center" DataIndex="VIZE3" Header="Vize3"
Sortable="true" Width="50">
<Editor>
<ext:NumberField ID="V3" runat="server" SelectOnFocus="true" MinValue="0"
MaxValue="100" AllowDecimals="false" HideTrigger="true" />
</Editor>
</ext:Column>
<ext:Column ID="Column19" runat="server" Align="Center" DataIndex="VIZE4" Header="Vize4"
Sortable="true" Width="50">
<Editor>
<ext:NumberField ID="V4" runat="server" SelectOnFocus="true" MinValue="0"
MaxValue="100" AllowDecimals="false" HideTrigger="true" />
</Editor>
</ext:Column>
<ext:Column ID="Column20" runat="server" Align="Center" DataIndex="VIZE5" Header="Vize5"
Sortable="true" Width="50">
<Editor>
<ext:NumberField ID="V5" runat="server" SelectOnFocus="true" MinValue="0"
MaxValue="100" AllowDecimals="false" HideTrigger="true" />
</Editor>
</ext:Column>
<ext:Column ID="Column21" runat="server" Align="Center" DataIndex="FINAL" Header="Final"
Sortable="true" Width="50">
<Editor>
<ext:NumberField ID="FINAL" runat="server" SelectOnFocus="true" MinValue="0" MaxValue="100" AllowDecimals="false" HideTrigger="true" />
</Editor>
</ext:Column>

<ext:Column ID="Column6" runat="server" Align="Center" DataIndex="ORT" Header="Ort"
Sortable="true" Width="50" >
<Renderer Fn="myRenderer1" />
</ext:Column>

<ext:Column ID="Column23" runat="server" Align="Center" DataIndex="HARFNOTU" Header="G.Not"
Sortable="true" Width="50" />
</Columns>
</ColumnModel>

<Plugins>
<ext:CellEditing ID="CellEditing2" ClicksToEdit="1" runat="server" >
<Listeners>
<BeforeEdit Handler="return !e.grid.lockEditing;" />
</Listeners>
</ext:CellEditing>
</Plugins>

<View>
<ext:GridView ID="GridView2" runat="server" EmptyText="Sistemde G?r?nt?lenecek Bilgi Yok"
StripeRows="true" TrackOver="true" LoadMask="true" LoadingText="Y?kleniyor...">
<GetRowClass Fn="getRowClass" />
</ext:GridView>
</View>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel2" runat="server" SingleSelect="true">
<DirectEvents>
<Select OnEvent="Cell_Click2">
<ExtraParams>
<ext:Parameter Name="TCKIMLIKNO" Value="record.data.TCKIMLIKNO" Mode="Raw" />
</ExtraParams>
</Select>
</DirectEvents>
</ext:RowSelectionModel>
</SelectionModel>


<Listeners>
<Render Handler="this.getSelectionModel().onEditorKey = myOnEditorKey;" />
</Listeners>



<ToolTips>
<ext:ToolTip ID="ToolTip5"
runat="server"
Delegate=".x-grid-cell"
TrackMouse="true" Title="Sarı Alanın Anlamı" >
<Listeners> <Show Handler="return false;" />
<Show Handler="onBeforeShow(this, #{GridPanel2});" />
</Listeners>
</ext:ToolTip>
</ToolTips>

</ext:GridPanel>

Daniil
Dec 07, 2014, 9:07 PM
Hi @cottimucin,

These threads look helpful.
http://forums.ext.net/showthread.php?21924
http://forums.ext.net/showthread.php?23193