PDA

View Full Version : [CLOSED] PropertyGrid editor issue



bossun
Aug 24, 2012, 2:40 PM
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(USERI D,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.

Daniil
Aug 24, 2012, 3:08 PM
Hi,

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

If should re-render the PropertyGrid.

PropertyGrid.Render();

bossun
Aug 24, 2012, 3:14 PM
If should re-render the PropertyGrid.

PropertyGrid.Render();
Doesn't work. Already tryied.



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?

Daniil
Aug 26, 2012, 7:39 AM
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:
http://examples2.ext.net/#/PropertyGrid/Basic/Overview/

Daniil
Aug 28, 2012, 6:47 AM
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.

bossun
Aug 28, 2012, 2:03 PM
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

Daniil
Aug 28, 2012, 2:15 PM
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 (http://docs.sencha.com/ext-js/4-1/#%21/api/Ext.view.AbstractView-cfg-emptyText)

Help_Developer
Nov 15, 2012, 2:08 AM
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>

Daniil
Nov 15, 2012, 9:39 AM
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.

Daniil
May 20, 2013, 4:52 AM
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>

bossun
May 20, 2013, 8:36 AM
Yes, it's true.

Excellent work.