[CLOSED] PropertyGrid editor issue

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] PropertyGrid editor issue

    Hi every one,

    I'm trying to set the editor for each property by code-begind but doesn't work. The editor is TextFied for all attributes.

    Here is my code.

                                    <ext:PropertyGrid runat="server" 
                                    ID="UserCustomAttributes"
                                    Title="<%$ Resources:Resource,CustomAttributes %>"
                                    >
                                    <Source>
                                        <ext:PropertyGridParameter></ext:PropertyGridParameter>
                                    </Source>
                                    </ext:PropertyGrid>

    protected void LoadCustomAttributes(int USERID)
        {
            DataTable dt = SigmaSportUser.UserSelect_AllCutomAttributes(USERID,1);
            PropertyGridParameterCollection pList = new PropertyGridParameterCollection();
            
            foreach (DataRow dr in dt.Rows)
            {
                PropertyGridParameter param = new PropertyGridParameter();            
                param.Value = dr["VALUE"].ToString();
                param.DisplayName = dr["ATTRIBUTEID"].ToString();
                param.Name = dr["ATTRIBUTEID"].ToString();
    
                switch(dr["DATATYPE"].ToString())
                {
                    case "System.String":
                        {
                            TextField tf = new TextField();
                            tf.AllowBlank = false;                        
                            param.Editor.Add(tf);
                            break;
                        }
                    case "System.DateTime":
                        {
                            DateField df = new DateField();
                            df.AllowBlank = false;
                            param.Editor.Add(df);
                            break;
                        }
                }
                pList.Add(param);
            }
            UserCustomAttributes.SetSource(pList);
            UserCustomAttributes.DoLayout();
        }
    Wha am I doing wrong?

    Thank you very much.
    Last edited by Daniil; Nov 19, 2012 at 9:21 AM. Reason: [CLOSED]
  2. #2
    Hi,

    As far as I can remember the SetSource method can't set up Editors.

    If should re-render the PropertyGrid.
    PropertyGrid.Render();
  3. #3
    Quote Originally Posted by Daniil View Post
    If should re-render the PropertyGrid.
    PropertyGrid.Render();
    Doesn't work. Already tryied.

    Quote Originally Posted by Daniil View Post
    As far as I can remember the SetSource method can't set up Editors.
    How should I populate my propertygrid in order to get editors?
  4. #4
    Quote Originally Posted by bossun View Post
    Doesn't work. Already tryied.
    Please always provide more details. Just "doesn't work" doesn't help us much.

    I think explicit IDs are required for the PropertyGrid container and the Parameter Editor field.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Populate(object sender, DirectEventArgs e)
        {
            PropertyGridParameter p = new PropertyGridParameter();
            p.Name = "name 1";
            p.Value = "value 1";
            p.Editor.Add(new ComboBox() { ID = "ComboBox1" });
    
            this.PropertyGrid1.Source.Add(p);
            this.PropertyGrid1.Render();
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:Container
                ID="Container1"
                runat="server" 
                Width="300" 
                Height="300" 
                Layout="FitLayout">
                <Items>
                    <ext:PropertyGrid 
                        ID="PropertyGrid1" 
                        runat="server" 
                        ForceFit="true">
                        <Source>
                            <ext:PropertyGridParameter Name="initial" Value="initial" />
                        </Source>
    
                        <Buttons>
                            <ext:Button runat="server" Text="Populate">
                                <DirectEvents>
                                    <Click OnEvent="Populate" />
                                </DirectEvents>
                            </ext:Button>
                        </Buttons>           
                    </ext:PropertyGrid>
                </Items>
            </ext:Container>
        </form>
    </body>
    </html>
    I will discuss it with my colleagues.

    Also you can use the PropertyGrid AddProperty method as here:
    https://examples2.ext.net/#/Property...asic/Overview/
  5. #5
    Quote Originally Posted by Daniil View Post
    I think explicit IDs are required for the PropertyGrid container and the Parameter Editor field.

    I will discuss it with my colleagues.
    It is required for the Container, but not for the Editor field. The last one is fixed in SVN. So, the ComboBox ID can be removed in my example.

    Also you can remove this
    <Source>
        <ext:PropertyGridParameter Name="initial" Value="initial" />
    </Source>
    Now the PropertyGrid can be rendered without any Source.

    Also I reported it to Sencha.
    http://www.sencha.com/forum/showthread.php?239386

    When we will update ExtJS, we will remove our temporary fix.
  6. #6
    Hi Daniil

    Thank you for your answer.

    I downloaded the source code (revision 4300) and compiled. It seems to work better but I sill need to create a PropertyGridParameter manually.

    The firs load if my property grid doesn't contains any source, my page doesn't load.

    With the new version I can clear properties. When my gridparameter doesn't contains any source, it's not rendered but I don't get any error. So for me it suits well, I can accept this behaviour but it would have been better to get displayit with empty parameters or display a message like "No paramets to display"


    Thank you
  7. #7
    Quote Originally Posted by bossun View Post
    it would have been better to get displayit with empty parameters or display a message like "No paramets to display"
    Please set up EmptyText for View.
    http://docs.sencha.com/ext-js/4-1/#!/api/Ext.view.AbstractView-cfg-emptyText
  8. #8

    Unable to bind data to PropertyGrid using JsonData or AjaxStoreResult

    Click image for larger version. 

Name:	Test.png 
Views:	85 
Size:	14.5 KB 
ID:	5085
    Server-Side Code:

    public JsonResult GetProperties()
            { 
    
    var propertyObj =  new Dictionary<string, string>();
    
                         propertyObj.Add(pkgProps[0].Name, pkgProps[0].Value );
                         propertyObj.Add(pkgProps[1].Name, pkgProps[1].Value);
                         propertyObj.Add(pkgProps[2].Name, pkgProps[2].Value);
                         propertyObj.Add(pkgProps[3].Name, pkgProps[3].Value);
                         propertyObj.Add(pkgProps[4].Name, pkgProps[4].Value);
                         propertyObj.Add(pkgProps[5].Name, pkgProps[5].Value);
                         propertyObj.Add(pkgProps[6].Name, pkgProps[6].Value);
    
                        var r = new StoreResponseData();
                        r.Data = JSON.Serialize(propertyObj).ToString();
    
         return Json( 
                           new PropertyGridValues
                            {
                                
                                tom = pkgProps[0].Value,
                                skunk = pkgProps[1].Value,
                                sqirl = pkgProps[2].Value,
                                lock = pkgProps[3].Value,
                                luk = pkgProps[4].Value,
                                id = pkgProps[5].Value,
                                isrev = pkgProps[6].Value
                            });
    
    }
    
    tried as well
    public AjaxStoreResult GetProperties()
            { 
    ...........
    .........
       var r = new StoreResponseData();
                        r.Data = JSON.Serialize(propertyObj).ToString();
     // return new AjaxStoreResult(r.Data);
    
    
            }

    Client Side code:


    <ext:PropertyGrid ID="propGrid" runat="server" Title="Properties" Height="270" EnableViewState="true"
                                                                                
    StoreID="dsProperties" Width="600" FieldLabel="Properties" Name="" Values="Editor" DisplayField="sku"
                                                                                
    ValueField="Value" Mode="Default" Editable="false" EmptyText="product type" Resizable="true"
                                                                                
    LazyInit="false" AutoDataBind="true" ViewStateMode="Enabled" AutoFocus="true"  
    IDMode="Legacy"
                                                                                 
    Browsable="false">
                                                             
     <Store>
                                                                                    
    <ext:Store ID="dsProperties" runat="server" AutoLoad="true" Json="true" >
                                                                                        
    <Proxy>
                                                                                        
        <ext:HttpProxy Url="/Data/GetProperties/" />
                                                                                      
      </Proxy>
                                                                                        
    <Reader>
                                                                                           
     <ext:JsonReader IDProperty="propGrid" Root="data" TotalProperty="total">
                                                                                             
       <Fields>
                                                                                                  
      <ext:RecordField Name="tom" />
                                                                                                 
       <ext:RecordField Name="skunk" />
                                                                     
       <ext:RecordField Name="sqirl" />
          <ext:RecordField Name="lock " />  
          <ext:RecordField Name="luk " />                                                                                                                                                   
      <ext:RecordField Name="id" />
                                                                                                    
    <ext:RecordField Name="rev" />
                                                                                               
     </Fields>
                                                                                           
     </ext:JsonReader>
                                                                                        
    </Reader>
                                                                                        
    <BaseParams>
                                                                                            
    <ext:Parameter Name="filter" Value="#{txtFilter}.getValue()" Mode="Raw" />
                                                                                        
    </BaseParams>
                                                                                           
    <Listeners>
                                                                                                
    <BeforeRender Fn="propertiesLoaded" StopEvent="true" />
                                                                                             
    </Listeners>
                                                                                    
    </ext:Store>
                                                                                
    </Store>
                                                                                
    <Source>
                                                                                  
    <ext:PropertyGridParameter Name="tom">
                                                                                       
    <Editor>
                                                                                          
     <ext:TextField ID="tom" runat="server" Enabled="true" />
                                                                                       
     </Editor>
                                                                                    
    </ext:PropertyGridParameter>
                                                                                       
    <ext:PropertyGridParameter Name="skunk">
                                                                                        
    <Editor>
                                                                                     
     <ext:TextField ID="skunk" runat="server" Enabled="true" />
                                                                                       
     </Editor>
                                                                                   
     </ext:PropertyGridParameter>
                                                                                    
    <ext:PropertyGridParameter Name="sqr">
                                                                                      
     <Editor>
                                                                                          
    <ext:TextField ID="sqr" runat="server" Enabled="true" />
    
    ....</ext:PropertyGrid>
    Last edited by Daniil; Nov 15, 2012 at 8:36 AM. Reason: Please use [CODE] tags
  9. #9
    Hi @Help_Developer,

    Please start a new forum thread. If you feel the threads are related, please feel free to cross link between the two.
  10. #10
    Hi @bossun,

    Now (v2.2 and the SVN trunk) the following works.

    Example
    <%@ Page Language="C#" %>
      
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
      
    <script runat="server">
        protected void Populate(object sender, DirectEventArgs e)
        {
            PropertyGridParameter p = new PropertyGridParameter();
            p.Name = "dynamic";
            p.Value = "property";
            p.Editor.Add(new ComboBox());
     
            this.PropertyGrid1.SetSource(new PropertyGridParameterCollection() { p }, true);
        }
    </script>
      
    <!DOCTYPE html>
      
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
      
            <ext:Button runat="server" Text="Populate" OnDirectClick="Populate" />
            <ext:PropertyGrid ID="PropertyGrid1" runat="server">
                <Source>
                    <ext:PropertyGridParameter Name="initial" Value="property" />
                </Source>
            </ext:PropertyGrid>
        </form>
    </body>
    </html>
Page 1 of 2 12 LastLast

Similar Threads

  1. HTML Editor Issue
    By GKG4 in forum 2.x Help
    Replies: 0
    Last Post: May 15, 2012, 6:44 AM
  2. [CLOSED] PropertyGrid with combobox editor
    By Marcelo in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Mar 14, 2012, 11:16 PM
  3. [CLOSED] HTML editor issue in v1.0
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 06, 2011, 2:23 PM
  4. [CLOSED] Issue with propertyGrid params viewstate
    By edigital in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Feb 21, 2011, 6:39 PM
  5. PropertyGrid Big Issue.
    By dr.lam in forum 1.x Help
    Replies: 0
    Last Post: Jul 14, 2009, 11:17 PM

Tags for this Thread

Posting Permissions