[CLOSED] PropertyGrid error

  1. #1

    [CLOSED] PropertyGrid error

    Hi All,

    I'm using a Propertygrid to do my property page.

    I just load the properties on the grid when users select something before, like a type of property must be loaded for example.

    When user select the property, I populate the grid, and at the first time the page is loaded occur this error when user clicks in the first column

    Click image for larger version. 

Name:	property_grid_error.png 
Views:	94 
Size:	51.9 KB 
ID:	3924

    Message at Message Box

    "
    Runtime Error in Microsoft JScript: Can't get property value 'record': the object is null or not defined
    "

    and that's the code I'm using to add a properties in ajax event

    public void AddProperty(IPropriedade item)
            {
                Ext.Net.PropertyGridParameter param = new Ext.Net.PropertyGridParameter();
                param.Name = item.Nome;
                param.Value = item.Valor.ToString();
                param.Editor.Add((Ext.Net.Field)item.Editor);
                param.Mode = ParameterMode.Value;
                this.Source.Add(param);
                base.AddProperty(param);
    
                this.SetSource(this.Source);
    
                Hashtable props =
                    ExtraParams.GetValue(Page.ToMainForm(), ClientID + "Props") as Hashtable;
    
                props[item.Nome] = item;
    
            }
    Last edited by Daniil; Mar 13, 2012 at 8:26 AM. Reason: [CLOSED]
  2. #2
    Hi,

    I see
    this.selModel.grid.getSelectionModel...
    code.

    This looks very strange, I guess it can look just:
    this.getSelectionModel...
    Though, anyways, I think it doesn't cause the error.

    I have no idea what might cause the problem looking at your code. Could you provide a full sample to reproduce?
  3. #3
    Hi Daniil,

    Based on this example https://examples1.ext.net/#/Property...asic/Overview/

    add this code

    protected void Page_Load(object sender, EventArgs e)
        {
    
            PropertyGrid1.DirectEvents.CellClick.Event += new ComponentDirectEvent.DirectEventHandler(CellClick_Event);
    
            //here I need to get the current cell using this sintaxe, because my propertygrid is my own component
            PropertyGrid1.DirectEvents.CellClick.ExtraParams.Add(new Ext.Net.Parameter()
            {
                Mode = Ext.Net.ParameterMode.Raw,
                Name = "pars",
    
                //I just need to get the selected row
                Value = "Ext.encode(this.selModel.grid.getSelectionModel().selection.record.id)",
            });
        }
    
        void CellClick_Event(object sender, DirectEventArgs e)
        {
            PropertyGrid1.AddScript("alert('{0}');", e.ExtraParams[0].ToString());
        }
    
    protected void Button1_Click(object sender, DirectEventArgs e)
        { ....

    Follow these steps to reproduce the error

    First attempt
    1. Run your app;
    2. Click at first column (name);
    ** the error occurs ** :(

    3. Push "Continue"button;
    4. Click again;
    ** the error don't occurs ** :)

    But ... the strange symptom is, at this case, the message box always will show the last cell value.

    ------------------------------------------------
    Second attempt:
    1. Run your app;
    2. Click at second column (value);
    ** the error don't occurs ** :)

    This error only occurs at first page load
  4. #4
    Well, there is no selection when you click the PropertyGrid at the first time, therefore the following:
    grid.getSelectionModel().selection.record
    causes a JavaScript error, because "selection" is null.

    I can suggest this:
    Value = "this.getStore().getAt(rowIndex).id"
    instead of
    Value = "Ext.encode(this.selModel.grid.getSelectionModel().selection.record.id)"
    See also
    http://docs.sencha.com/ext-js/3-4/#!...vent-cellclick
  5. #5
    Thanks Daniil,

    Works fine for me :)

Similar Threads

  1. [CLOSED] DropDownField error when used in a PropertyGrid
    By rse in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Mar 25, 2011, 4:26 AM
  2. Error in example PropertyGrid > Basic > Overview
    By george.paoli in forum Bugs
    Replies: 1
    Last Post: Nov 17, 2010, 9:05 PM
  3. Replies: 2
    Last Post: May 31, 2010, 5:27 AM
  4. Several error in PropertyGrid
    By Kaido in forum Bugs
    Replies: 0
    Last Post: Sep 29, 2009, 5:02 AM
  5. [CLOSED] PropertyGrid
    By Bernard Jourdain in forum 1.x Help
    Replies: 2
    Last Post: Oct 06, 2008, 1:58 PM

Tags for this Thread

Posting Permissions