PDA

View Full Version : [CLOSED] Set complex objects to custom config value during direct event



bayoglu
May 22, 2013, 2:04 PM
Hello,

I have custom config definitions for a viewport and I can set complex values (Dictionary object, List etc.) during page load as below:



code behind:

MyViewport.Set("MyCustomConfig", MyDictionary);


It works fine during page load.

How can I re-set "MyCustomConfig" in a direct event call? MyViewport.Set("MyCustomConfig", MyDictionary) has no effect.

I tried using MyViewport.AddScript("App.MyViewport.MyCustomConfig = {0};", MyDictionary) but it does not work.

Any idea?

Thanks.

Daniil
May 22, 2013, 3:42 PM
Hi @bayoglu,

It appears to be working for me.

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.Viewport1.Set("customProperty", new { test = "initial"});
}
}

protected void Change(object sender, DirectEventArgs e)
{
this.Viewport1.Set("customProperty", new { test = "dynamic" });
}
</script>

<!DOCTYPE html>
<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:Viewport ID="Viewport1" runat="server">
<Items>
<ext:Button
runat="server"
Text="Show customProperty"
Handler="alert(Ext.encode(App.Viewport1.customProperty));" />

<ext:Button
runat="server"
Text="Change customProperty"
OnDirectClick="Change" />
</Items>
</ext:Viewport>
</form>
</body>
</html>


By the way, during initial loading it might be better to use a Viewport's CustomConfig instead of its Set method.

bayoglu
May 22, 2013, 3:44 PM
Hello @Daniil,

My mistake, sorry.
Please mark as closed.