[CLOSED] Propertygrid questions

  1. #1

    [CLOSED] Propertygrid questions

    Hi,

    I'm populating a propertygrid from code. This works, when adding a single propertyparameter in html. But without any the grid appears emtpy:

    aspx
    <%@ page language="C#" autoeventwireup="true" codefile="Parameters.aspx.cs" inherits="Admin_Parameters" LCID="1043" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Parameterbeheer</title>
        <link href="../style/examples.css" rel="stylesheet" type="text/css" />
        <style type="text/css">
            .data th {
                font-weight : bold;
            }
     
            .data th, .data td {
                padding : 4px;
                border  : 1px solid black;
            }
     
            .red-label{
                color:Red;
            }
     
            .blue-label{
                color:Blue;
            }
        </style>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" Theme="Gray"/>
            <ext:Viewport ID="Viewport1" runat="server">
            <Items>
            <ext:PropertyGrid 
                ID="PropertyGrid1"   
                runat="server" 
                Width="400" 
                AutoHeight="true" 
                >
                <Source>
                  <%-- <ext:PropertyGridParameter Name="Volledige synchronisatie" Value="false" Mode="Raw" />--%>
                </Source>
                <View>
                    <ext:GridView ForceFit="true" ScrollOffset="2" runat="server"/>
                </View>
                <TopBar>
                    <ext:Toolbar ID="tbParameters" Height="27" runat="server">
                            <Items>
                                <ext:Button ID="tbOpslaan" runat="server" Text="Opslaan" Icon="Disk">
                                   <DirectEvents>
                                        <Click OnEvent="Button1_Click" />
                                    </DirectEvents>
                                </ext:Button>
                            </Items>
                        </ext:Toolbar>    
                </TopBar>
                <Listeners>
                    <Render Handler="this.getStore().sortInfo = undefined;"/>
                </Listeners>         
            </ext:PropertyGrid>
            </Items>
            </ext:Viewport>
     
            <p><ext:Label ID="Label1" runat="server" /></p>
        </form>
     
    </body>
    </html>
    Code
    using System;
    using System.Data;
    using System.Data.SqlClient;
    using System.Text;
    using Ext.Net;
     
    public partial class Admin_Parameters : System.Web.UI.Page
    {
     
        protected void Page_Load(object sender, EventArgs e)
        {
     
        //if (iWiseC.myUtils.getKlant("bIsAdmin") != "1") Response.Redirect("~/default.aspx");
        if (!ExtNet.IsAjaxRequest)
           {
            // Boolean bLease = iWiseC.myUtils.getKlant("bLease").ToLower() == "true";
            const bool bLease = true;
            //Boolean bRent = iWiseC.myUtils.getKlant("bRent").ToLower() == "true";
            const bool bRent = true;
     
            // Applicatienaam
            var ptyApplicatieNaam = new PropertyGridParameter { };
            ptyApplicatieNaam.DisplayName = "Applicatienaam";
            ptyApplicatieNaam.Name = "applicatienaam";
            //ptyApplicatieNaam.Value = iWiseC.myUtils.getKlant("cApplicatienaam");
            ptyApplicatieNaam.Value = "Naam";
            var atf = new TextField
            {
                Name = "tfApplicatieNaam",
                AllowBlank = false,
            };
            ptyApplicatieNaam.Editor.Add(atf);
            PropertyGrid1.AddProperty(ptyApplicatieNaam);
     
            // Desktoptekst
            var ptyDesktopTekst = new PropertyGridParameter { };
            ptyDesktopTekst.DisplayName = "Desktop tekst";
            ptyDesktopTekst.Name = "desktoptekst";
            //ptyDesktopTekst.Value = iWiseC.myUtils.getKlant("cApplicatienaam");
            ptyDesktopTekst.Value = "Tekst";
            var ta = new TextArea
                            {
                                Name = "taDesktopTekst",
                                Height = 100,
                                Width = 300,
                            };
            ptyDesktopTekst.Editor.Add(ta);
            PropertyGrid1.AddProperty(ptyDesktopTekst);
     
            // Loginnaam
             var ptyLoginNaam = new PropertyGridParameter { };
             ptyLoginNaam.DisplayName = "Loginnaam";
             ptyLoginNaam.Name = "Loginnaam";
             //ptyLoginNaam.Value = iWiseC.myUtils.getKlant("cLogin");
             ptyLoginNaam.Value = "LoginNaam";
             var ptf = new TextField
                             {
                                 Name = "tfLoginNaam",
                                 AllowBlank = false
                              };
             ptyLoginNaam.Editor.Add(ptf);
             PropertyGrid1.AddProperty(ptyLoginNaam);
     
            // Wachtwoord
            var ptyWachtwoord = new PropertyGridParameter { };
            ptyWachtwoord.DisplayName = "Wachtwoord";
            ptyWachtwoord.Name = "Wachtwoord";
            //ptyWachtwoord.Value = iWiseC.myUtils.getKlant("cWachtwoord");
            ptyWachtwoord.Value = "Wachtwoord";
            var wtf = new TextField
            {
                Name = "tfWachtwoord",
                AllowBlank = false,
            };
            ptyWachtwoord.Editor.Add(wtf);
            PropertyGrid1.AddProperty(ptyWachtwoord);
     
            if (bLease)
            {
                // Wijzigen bestuurder
                var ptyWijzigenBestuurder = new PropertyGridParameter {};
                ptyWijzigenBestuurder.DisplayName = "Wijzigen Bestuurder"; 
                ptyWijzigenBestuurder.Name = "changeDriver";
                ptyWijzigenBestuurder.Value = "false";
                ptyWijzigenBestuurder.Mode = Ext.Net.ParameterMode.Raw;
                PropertyGrid1.AddProperty(ptyWijzigenBestuurder);
     
                // Email voor wijziging bestuurder
                var ptyEmailWijzigenBestuurder = new PropertyGridParameter { };
                ptyEmailWijzigenBestuurder.DisplayName = "Email bestuurderwijzigingen";
                ptyEmailWijzigenBestuurder.Name = "changeDriverEmail";
                //ptyEmailWijzigenBestuurder.Value = iWiseC.myUtils.getKlant("cEmailBestuurderWijziging");
                ptyEmailWijzigenBestuurder.Value = "martin@email.com";
                var tf = new TextField
                             {
                                 Name = "tfchangeDriverEmail",
                                 Vtype = "email",
                             };
                ptyEmailWijzigenBestuurder.Editor.Add(tf);
                PropertyGrid1.AddProperty(ptyEmailWijzigenBestuurder);
     
                var ptyKmAfwijking = new PropertyGridParameter { };
                ptyKmAfwijking.DisplayName = "Afwijking km invoer (%)";
                ptyKmAfwijking.Name = "margeKmInvoer";
                //ptyKmAfwijking.Value = iWiseC.myUtils.getKlant("nToegestaneKmAfwijking");
                ptyKmAfwijking.Value = "20";
                var nf = new NumberField
                             {
                                 Name = "nfAfwijking",
                                 MaxValue = 100,
                                 MinValue = 1,
                                 AllowBlank = false,
                             };
                ptyKmAfwijking.Editor.Add(nf);
                PropertyGrid1.AddProperty(ptyKmAfwijking);
            }
     
            if (bRent)
            {
                // Wijzigen bestuurder
                var ptyInvoerWebReservering = new PropertyGridParameter { };
                ptyInvoerWebReservering.DisplayName = "Invoer webreservering";
                ptyInvoerWebReservering.Name = "insertWebReservation";
                ptyInvoerWebReservering.Value = "false";
                ptyInvoerWebReservering.Mode = Ext.Net.ParameterMode.Raw;
                PropertyGrid1.AddProperty(ptyInvoerWebReservering);
     
            }
     
            // Facturen tonen
     
            var ptyTonenFacturen = new PropertyGridParameter {};
            ptyTonenFacturen.DisplayName = "Tonen facturen"; 
            ptyTonenFacturen.Name = "showFacturen";
            ptyTonenFacturen.Value = "false";
            ptyTonenFacturen.Mode = Ext.Net.ParameterMode.Raw;
            PropertyGrid1.AddProperty(ptyTonenFacturen);
     
            // Volledige Synchronisatie
     
            var ptyVolledigeSynchronisatie = new PropertyGridParameter {};
            ptyVolledigeSynchronisatie.DisplayName = "Volledige synchronisatie"; 
            ptyVolledigeSynchronisatie.Name = "volledigeSynchronisatie";
            ptyVolledigeSynchronisatie.Value = "false";
            ptyVolledigeSynchronisatie.Mode = Ext.Net.ParameterMode.Raw;
            PropertyGrid1.AddProperty(ptyVolledigeSynchronisatie);
           }
        }
     
        protected void Button1_Click(object sender, DirectEventArgs e)
        {
          // Save parameters
     
        }
     }
    Also. How to change the headers of the propertygrid. Now it's "Name", "Value", but I would like to make them "Naam", "Waarde"

    And last question :)

    Is it possible to change true/false of those specific propertyparameters in yes/no or (dutch) ja/nee. Or do I need to create a dropdownlist myself (editor)

    Regards,

    Martin
    Last edited by Daniil; Jun 27, 2011 at 12:38 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Unfortunately, I 'm getting "There is no iWiseC in this context" exception. And could you simplify the code?
    How to change the headers of the propertygrid. Now it's "Name", "Value", but I would like to make them "Naam", "Waarde"
    I can suggest this way:
    <ext:ResourcePlaceHolder runat="server" />
    <script type="text/javascript">
        Ext.grid.PropertyColumnModel.override({
            nameText : 'My Name',
            valueText : 'My Value'
        });
    </script>
    By the way these properties are private and used for localization purpose. This code is from ExtJS sources:
    Ext.grid.PropertyColumnModel = Ext.extend(Ext.grid.ColumnModel, {
        // private - strings used for locale support
        nameText : 'Name',
        valueText : 'Value',
    Is it possible to change true/false of those specific propertyparameters in yes/no or (dutch) ja/nee. Or do I need to create a dropdownlist myself (editor)
    Here is the same situation. Please look at the example.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
        <ext:ResourcePlaceHolder runat="server" />
    
        <script type="text/javascript">
            Ext.grid.PropertyColumnModel.override({
                nameText : 'My Name',
                valueText : 'My Value',
                trueText : "Yes",
                falseText : "No"
            });
        </script>
    
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:PropertyGrid runat="server" Width="200" AutoHeight="true">
                <Source>
                    <ext:PropertyGridParameter Name="Prop1" Value="true" Mode="Raw">
                        <Renderer Handler="return value ? 'Yes' : 'No';" />
                    </ext:PropertyGridParameter>
                    <ext:PropertyGridParameter Name="Prop2" Value="test" />
                </Source>
            </ext:PropertyGrid>
        </form>
    </body>
    </html>
  3. #3
    Regarding the first problem. The sample below appears to be working fine.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.PropertyGrid1.Source.Add(new PropertyGridParameter()
                {
                    Name = "Prop1",
                    Value = "true",
                    Mode = ParameterMode.Raw       
                });
                this.PropertyGrid1.Source.Add(new PropertyGridParameter()
                {
                    Name = "Prop2",
                    Value = "test",
                    Mode = ParameterMode.Value
                });  
            }
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:PropertyGrid 
                ID="PropertyGrid1" 
                runat="server" 
                Width="200" 
                AutoHeight="true" />
        </form>
    </body>
    </html>
  4. #4
    Quote Originally Posted by Daniil View Post
    Hi,

    Unfortunately, I 'm getting "There is no iWiseC in this context" exception. And could you simplify the code?
    Forgot to comment that line. Changed it..

    Can you look into it ?

    martin
  5. #5
    Foud it..

    Using PropertyGrid1.Source.Add instead of PropertyGrid1.AddProperty solves the issue.

    Will look into your other solutions. Thanks Daniil !
  6. #6
    Yes, please use .AddProperty() during DirectEvent.
  7. #7
    Quote Originally Posted by Daniil View Post
    Yes, please use .AddProperty() during DirectEvent.
    Hi, I'm using AddProperty during DirectEvent and the items will not show up unless I add at least one property on the markup code.

    Sample code:

    for (int i = 0; i < 15; i++)        {     
                PropertyGridParameter param = new PropertyGridParameter();
                param.Name = i.ToString();
                param.DisplayName = "Param " + (i + 1).ToString();
                param.Value = Guid.NewGuid().ToString();
                PropertyGrid1.AddProperty(param);
            }
  8. #8
    Hi,

    In this case I would suggest to rerender the PropertyGrid calling its Render method.

    It might require to place the PropertyGrid into a separate container to do not lose its position on the page.

Similar Threads

  1. [CLOSED] How to-do Questions
    By SymSure in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 15, 2011, 3:16 PM
  2. [CLOSED] Questions
    By farisqadadeh in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Mar 27, 2011, 9:45 AM
  3. [CLOSED] [1.0] Couple MVC questions and property questions
    By alliedwallet.com in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Dec 28, 2010, 11:01 AM
  4. Questions
    By fredba in forum Licensing
    Replies: 1
    Last Post: Jun 15, 2010, 6:19 PM
  5. [CLOSED] MVC questions
    By BGeorge in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jan 23, 2009, 5:50 PM

Tags for this Thread

Posting Permissions