English 中文(简体)
需视文中的实地内容,进行实地校正。 NET。 这一点。 具体目标无效或不为物体错误
原标题:Need to get a field editable depending on a field content in EXT.NET. Get this.field.msgTarget is null or not an object error
  • 时间:2012-01-13 19:06:28
  •  标签:
  • ext.net

I try to use your example to dynamically add/remove editor and get this error: this.field.msgTarget is null or not an object error. I m new to the ext.net - could somebody help me? Thanks, Jenny

this is my code: EditExample.aspx:

   <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EditExample.aspx.cs"        Inherits="myApp.EditExample" %>

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0  Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

  <html xmlns="http://www.w3.org/1999/xhtml">
  <head runat="server">
  <title></title>
  <script type="text/javascript">
      var setEditor = function (e) {
         var column = e.grid.getColumnModel().columns[e.column],
         ed = column.getCellEditor(e.row);
         if (ed && (e.value != null || e.value !=   )) {
            ed.destroy();
         }
         else {
            column.setEditor(new Ext.form.TextField());
         }
     }
 </script>

 </head>
 <body>
 <form id="form1" runat="server">

 <ext:ResourceManager runat="server" />
 <ext:Store ID="extStore" runat="server" >
 <Reader>
    <ext:JsonReader>
    <Fields>
       <ext:RecordField Name = "Name" />
       <ext:RecordField Name = "Code" ></ext:RecordField>
       <ext:RecordField Name = "Description" ></ext:RecordField>
    </Fields>
    </ext:JsonReader>
 </Reader>
 </ext:Store>
 <div>
 <ext:GridPanel ID="extGrd" runat="server" StripeRows="true" TrackMouseOver="true"
 StoreID="extStore" Cls="x-grid-custom" 

 Height="250px" Layout="fit">
 <ColumnModel ID="cmFC" runat="server"> 
 <Columns>
    <ext:Column ColumnID="Name" DataIndex="Name" Header="Name">
    </ext:Column>
    <ext:Column ColumnID="Code" DataIndex="Code" Header="Code">
    </ext:Column>
    <ext:Column ColumnID="Description" DataIndex="Description" Header="Description"  Editable ="true" >
        <Editor>
        <ext:TextField ID="TextField1" runat="server"></ext:TextField>
        </Editor>
        </ext:Column>
   </Columns> 
</ColumnModel>
<Listeners>
    <BeforeEdit Fn="setEditor" />
    <Render Handler="this.getColumnModel().setEditable(0, true);" />
</Listeners>
<SelectionModel>
   <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true"   MoveEditorOnEnter="true"/>
</SelectionModel> 
<LoadMask ShowMask="true" />
</ext:GridPanel>
</div>

</form>
</body>
</html>

EditExample.aspx.cs

 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Web;
 using System.Web.UI;
 using System.Web.UI.WebControls;

 namespace myApp
 {
     public class info
     {
        public string Name { get; set; }
        public string Code { get; set; }
        public string Description { get; set; }
     }

     public partial class EditExample : System.Web.UI.Page
     {
         protected void Page_Load( object sender, EventArgs e )
         {
            List<info> thisInfo = new List<info>();
            thisInfo.Add( new info { Code = "1", Description = "one", Name = "one Name" } );
            thisInfo.Add( new info { Code = "2", Description = "two", Name = "two Names" } );
            thisInfo.Add( new info { Code = "3", Description = "three", Name = "three Names" } );
            thisInfo.Add( new info { Code = "4", Description = "four", Name = "four Names" } );
            thisInfo.Add( new info { Code = "5", Description = "five", Name = "five Names" } );
            thisInfo.Add( new info { Code = "6", Description = "six", Name = "six Names" } );

            this.extStore.DataSource = thisInfo;
            this.extStore.DataBind();
        }
    }

EDIT: I tried to make the field disabled and readonly. It made the field appear disabled (greyed out), but readable.

  var setEditor = function (e) 
  { 
        var column = e.grid.getColumnModel().columns[e.column], 
                    ed = column.getCellEditor(e.row); 
        if (ed) 
        { 
            if (e.value != null && e.value !=   ) 
            { 
               ed.readOnly = true; ed.setDisabled(true); 
            } 
            else 
            { 
                ed.readOnly = false; ed.setDisabled(false); 
            } 
        } 
  } 
最佳回答

You can just return false to before event.

var setEditor = function (e) {
          var column = e.grid.getColumnModel().columns[e.column],
          ed = column.getCellEditor(e.row);
          if (ed && (e.value !=   )) {
              return false;
          }
      }
问题回答

暂无回答




相关问题
Using the Ext.NET library in an ASP.NET Monodevelop project

I would like to use the wonderful Ext.NET library (.dll) inside a MonoDevelop project. Is it possible? If yes, how can I register it in my project to see the <ext:something> extension like ...

how to set(get) cookie value in ext.net

scene: when I click item in ext:ComboBox and want to set the item selected value to cookie variable. Finally, after I click ext:Button, the ext:Label get cookie value and display it. But I get a ...

Binding Combobox

I am developing a web application with Ext.Net. How can I bind combobox from database? This is my query: dynamic getRegions = ( from region in db.Regions orderby region.RgnName select ...

Ext.Net Button Event not firing

I am using Ext.Net and I have a problem. I am creating dynamic buttons. It is working but if i click, the button event is not working.:( How can I fix it? My code: foreach (var events in ...

How can I configure the Ext.NET Calendar Control?

I tried to configure the Ext.NET asp.net calendar control to view my own events but I don t have any idea how to do it? Also, Ext.NET Events class have their own fields but I need to put my own fields ...

i can t expand my ext:gridpanel

i have gridpanel in my page and i want to expand it (somthing like height=100%) but i can t find any property that can use this is my code this is my code : <ext:Panel runat="server" ID="...

热门标签