PDA

View Full Version : [CLOSED] [#223] Tracking changes of Fielset Content



Peter.Treier
Apr 28, 2013, 12:54 PM
Hi all

I have a Page with several Textfiels grouped in Fielsets. I need to indicate the presence of text in these Textfields by setting a Icon on the Fieldset.
The brute way is to set a Handler on each Textfield, but more elegant would be the tracking of a Fieldset event triggered by the Fieldset content.

Is there a way to do that ?

Peter

Daniil
Apr 29, 2013, 6:50 AM
Hi Peter,

Welcome to the Ext.NET forums!

A FieldSet doesn't listen its items' events.

Well, the best is to listen TextFields' event. You can attach listeners on a FieldSet level.

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html>
<html>
<head runat="server">
<title>Ext.NET v2 Example</title>

<script>
var onBeforeRender = function (fieldSet) {
var items = fieldSet.items.getRange(),
i;

for (i = 0; i < items.length; i++) {
items[i].on("change", onTextFieldChange, fieldSet);
}
};

var onTextFieldChange = function (textField) {
var fieldSet = this;

console.log("change");
};
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:FieldSet runat="server">
<Items>
<ext:TextField runat="server" />
<ext:TextField runat="server" />
</Items>
<Listeners>
<BeforeRender Fn="onBeforeRender" />
</Listeners>
</ext:FieldSet>

<ext:FieldSet runat="server">
<Items>
<ext:TextField runat="server" />
<ext:TextField runat="server" />
</Items>
<Listeners>
<BeforeRender Fn="onBeforeRender" />
</Listeners>
</ext:FieldSet>
</form>
</body>
</html>

Another approach could be using a FormPanel and its FieldValidityChange event.

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html>
<html>
<head runat="server">
<title>Ext.NET v2 Example</title>

<script>
var onFieldValidityChange = function (formPanel, textField) {
var fieldSet = textField.up("fieldset");

console.log("FieldValidityChange");
};
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:FormPanel runat="server">
<Items>
<ext:FieldSet runat="server">
<Items>
<ext:TextField runat="server" AllowBlank="false" />
<ext:TextField runat="server" AllowBlank="false" />
</Items>
</ext:FieldSet>

<ext:FieldSet runat="server">
<Items>
<ext:TextField runat="server" AllowBlank="false" />
<ext:TextField runat="server" AllowBlank="false" />
</Items>
</ext:FieldSet>
</Items>
<Listeners>
<FieldValidityChange Fn="onFieldValidityChange" />
</Listeners>
</ext:FormPanel>
</form>
</body>
</html>

Daniil
Apr 30, 2013, 10:25 AM
We added the FieldValidityChange event, but it doesn't fire due to an ExtJS bug.
http://www.sencha.com/forum/showthread.php?262559

Created an Issue to monitor it.
https://github.com/extnet/Ext.NET/issues/223

Baidaly
May 31, 2013, 3:25 AM
Hello!

The issue appears to be fixed in the SVN trunk. Please update.