PDA

View Full Version : [FIXED] [V0.6] NumberField and AjaxEvents



Timothy
Sep 10, 2008, 11:01 AM
Hello,

The example below demonstrates that the NumberField is not being set on AjaxEvents ComboBox change event.



<%@ Page Language="C#" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void drpBox_Change(object sender, AjaxEventArgs e)
{
txtName.Text = "Timothy";
txtPrice.Number = 1;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True" />
<ext:ScriptManager ID="ScriptManager2" runat="server" Theme="Gray" />
<ext:TabPanel ID="TabPanel" runat="server" ActiveTabIndex="0" AutoPostBack="True" AutoHeight="True" DeferredRender="True">
<Tabs>
<ext:Tab ID="Tab1" runat="server" Title="Tab1">
<Content>
<ext:ComboBox ID="drpBox" runat="server">
<Items>
<ext:ListItem Text="1" />
<ext:ListItem Text="2" />
</Items>
<AjaxEvents>
<Change OnEvent="drpBox_Change" />
</AjaxEvents>
</ext:ComboBox>
<ext:TextField ID="txtName" runat="server" />
<ext:NumberField ID="txtPrice" runat="server" AllowDecimals="True" DecimalPrecision="2" />
</Content>
</ext:Tab>
</Tabs>
</ext:TabPanel>
</form>
</body>
</html>


Cheers,
Timothy

Vladimir
Sep 10, 2008, 12:07 PM
Hi Timothy,



the fix in SVN

Timothy
Sep 10, 2008, 12:10 PM
Thanks vlad!

Cheers,
Timothy

Timothy
Sep 10, 2008, 4:41 PM
Hello,

Ext:HiddenField is the same.

Cheers,
Timothy

Timothy
Sep 10, 2008, 5:03 PM
Also the same for Ext:Store ... if I bind the data doesn't change.

geoffrey.mcgill
Sep 10, 2008, 6:35 PM
I cleaned up some of the code re: how the Form Fields set their value during an AjaxEvent. The <ext:HiddenField> should be working properly now. The same problem existed in <ext:DateField> and <ext:DatePicker>.

The cause of the defect is that a small snippit of JavaScript must be dynamically created during the AjaxEvent and returned to be executed on the client. By default when you set a property during the Ajax event, the snippit returned will just try to set the property value in JavaScript. For example, by default, if you set the .Text property of the <ext:TextField> to "testing", the snippit returned will be "this.TextField1.text = \"testing\"". Unfortunately that snippit of JavaScript will not actually update the <input> field and the TextField will appear to not change.

Updating some properties with the client widget requires a function to be called on the client. To change the .Text property of the <ext:TextField> on the client, you must call the .SetValue() function.

We've created a mechanism within the controls to enable a custom Method or custom snippit to be returned by setting the [AjaxEventUpdate] Attribute. For example, the .Text property of the <ext:TextField> requires the .SetValue() Method to be called, so the [AjaxEventUpdate(MethodName="SetValue")] is added to the .Text property.

The AjaxEventUpdate Attribute above instructs the serializer to call the .SetValue() Method when the .Text property is set during an AjaxEvent.

Other options for the AjaxEventUpdateAttribute include:


[AjaxEventUpdate(MethodName = "SetTitle")] // Call a Method
[AjaxEventUpdate(Script = "this.{0}.setTitle({1});")] // Supply a custom script Template. Two values passed, 1. .ClientID &amp; 2. the Json Serialized property value.
[AjaxEventUpdate] // AutoGenerate, returns a property setter
Properties that do not update properly on the respose from an AjaxEvent do not have the proper [AjaxEventUpdate] attribute applied.

We made an initial pass through the Toolkit setting many of the required [AjaxEventUpdate] attributes, but there's still many that require hand modification.

If you find a property that does not update on the client after the AjaxEvent response, please let us know. Revising the [AjaxEventUpdate] Attribute will almost always be the solution.

geoffrey.mcgill
Sep 10, 2008, 6:40 PM
Timothy (9/10/2008)Also the same for Ext:Store ... if I bind the data doesn't change.


Can you create a new thread for this bug report? I'm marking the original request as [FIXED].

Timothy
Sep 10, 2008, 6:59 PM
Great thanks Geoffrey.

Will do.

Timothy