Nov 18, 2009, 6:38 AM
[CLOSED] Dynamic Text Editor in grid error
As a follow on to this topic: http://forums.ext.net/showthread.php?4059
If I have a dynamic textfield editor as per the sample below. When I edit a row change the text and then click away from the row with the mouse, it all works fine.
But if you edit the row and change the text and hit return you get a "this.field.triggerBlur is null or not an object" error
then after it moves on to try and edit the next row. Ideally I would like it not to try and edit the next row just finish the edit.
Any idea why I get this error? and how I stop the edit moving to the next row?
If I have a dynamic textfield editor as per the sample below. When I edit a row change the text and then click away from the row with the mouse, it all works fine.
But if you edit the row and change the text and hit return you get a "this.field.triggerBlur is null or not an object" error
then after it moves on to try and edit the next row. Ideally I would like it not to try and edit the next row just finish the edit.
Any idea why I get this error? and how I stop the edit moving to the next row?
<%@ Page Language="VB" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Ext.IsAjaxRequest Then
Dim x As TestAttrib
Dim li As New System.Collections.Generic.List(Of TestAttrib)
For i As Integer = 1 To 10
x = New TestAttrib
x.Description = "Item " & i.ToString
x.AttributeID = i
li.Add(x)
Next
Me.StoreDetaineeAttributes.DataSource = li
Me.StoreDetaineeAttributes.DataBind()
End If
End Sub
Public Class TestAttrib
Private _Description As String
Private _AttributeID As Long
Property Description() As String
Get
Return _Description
End Get
Set(ByVal value As String)
_Description = value
End Set
End Property
Property AttributeID() As Long
Get
Return _AttributeID
End Get
Set(ByVal value As Long)
_AttributeID = value
End Set
End Property
End Class
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<script type="text/javascript">
var setEditor = function(e) {
var ed = e.grid.getColumnModel().getCellEditor(e.column, e.row) || {};
ed = ed.field || {};
e.grid.getColumnModel().setEditor(e.column, new Ext.grid.GridEditor(new Ext.form.TextField({
id: "field1"
})));
}
</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ScriptManager ID="ScriptManager1" runat="server" />
<ext:Store ID="StoreDetaineeAttributes" runat="server">
<Reader>
<ext:JsonReader ReaderID="AttributeTypeID">
<Fields>
<ext:RecordField Name="Description" Type="String" />
<ext:RecordField Name="AttributeID" Type="Int" />
</Fields>
</ext:JsonReader>
</Reader>
<SortInfo Field="Description" Direction="ASC" />
</ext:Store>
<ext:Panel ID="Panel5" StyleSpec="paddingLeft:3px;paddingTop:3px" runat="server"
Height="427" Width="450" Border="false" Header="false">
<Body>
<ext:FitLayout ID="FitLayout2" runat="server">
<ext:GridPanel ID="grdAttributes" StoreID="StoreDetaineeAttributes" runat="server"
ClicksToEdit="2" Header="true" Title="Detainee Attributes" Border="true" TrackMouseOver="true"
AutoExpandColumn="Description" EnableHdMenu="false">
<ColumnModel>
<Columns>
<ext:Column ColumnID="Description" DataIndex="Description" Header="Description" Width="150"
Align="Center">
<Editor>
<ext:TextField runat="server" ID="TextField1" Text="Some Text" />
</Editor>
</ext:Column>
<ext:Column ColumnID="AttributeID" DataIndex="AttributeID" Hidden="false" Header="AttributeID" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel runat="server" ID="RowSelectionCurrenyRows" />
</SelectionModel>
<Listeners>
<BeforeEdit Fn="setEditor" />
<Render Handler="this.getColumnModel().setEditable(0, true);" />
</Listeners>
</ext:GridPanel>
</ext:FitLayout>
</Body>
</ext:Panel>
</form>
</body>
</html>
Last edited by geoffrey.mcgill; Feb 21, 2011 at 8:08 PM.