PDA

View Full Version : [CLOSED] Field ReadOnly Javascript



Aurelio
Mar 21, 2012, 5:23 PM
HI, I have a problem, readOnly non work the set client-side,Server-side work ok, here is the example:



<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="ARWebRevolution.WebForm1" %>

<%@ 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 id="Head1" runat="server">
<title>Ext.NET v2 Example</title>

</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" >
</ext:ResourceManager>
<ext:FormPanel ID="FormPanel1" runat="server" ButtonAlign="Right" Height="185" Padding="5"
Title="Title" Width="300">
<Items>
<ext:NumberField ID="NumberField1" runat="server" ReadOnly="true">
</ext:NumberField>
<ext:TextField ID="TextField1" runat="server" >
</ext:TextField>
</Items>
<Buttons>
<ext:Button ID="Button1" runat="server" Icon="Disk" Text="Enable Field">
<Listeners>
<Click Handler="enableField();" />
</Listeners>
</ext:Button>
</Buttons>

</ext:FormPanel>

</form>
<script type="text/javascript" >

function enableField() {
App.NumberField1.readOnly = false;
App.TextField1.readOnly = true;

}

</script>
</body>
</html>




protected void enableField(object sender, DirectEventArgs e)
{
NumberField1.ReadOnly = false;

}

1) If click button only with function listener, readOnly non work
2)If click button only with function


<DirectEvents>
<Click OnEvent="enableField" />
</DirectEvents>

it's work ok,
3) With Direct and Listener not work.

Also if use readOnly the spinner to right of the field not is show.

Thank
Aurelio

Daniil
Mar 21, 2012, 5:31 PM
Hi,

Please use the setReadOnly method on client side instead of just setting the readOnly property.
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.form.field.Base-method-setReadOnly

Aurelio
Mar 21, 2012, 5:41 PM
Hi, Daniil, today my brain is malfunctioning !!!!

however the spinner not appear the readOnly is set to false to the function..

Thanks
Aurelio

Daniil
Mar 21, 2012, 6:31 PM
Confirmed, thanks for the report.

Here is the test case.

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 v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:NumberField ID="NumberField1" runat="server" ReadOnly="true" />
<ext:Button runat="server" Text="setReadOnly(false)">
<Listeners>
<Click Handler="App.NumberField1.setReadOnly(false);
// Doesn't work as well
// App.NumberField1.setReadOnly(false);
" />
</Listeners>
</ext:Button>
</form>
</body>
</html>

Daniil
Mar 21, 2012, 9:05 PM
Please update from SVN.

Aurelio
Mar 22, 2012, 12:15 AM
Hi, Daniil, ok work fine..but i have another problem with number field:
When setting the property MinValue = 0, if the value is 0, the value property returns null..
Here the sample:
1)Click the button enable field, it's setValue = 0
2)Click the button ShowValue, it's not show 0 but the value is null.
So I can not assign a value of 0 which is the minimum value



<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="ARWebRevolution.WebForm1" %>

<%@ 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 id="Head1" runat="server">
<title>Ext.NET v2 Example</title>

</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" >
</ext:ResourceManager>
<ext:FormPanel ID="FormPanel1" runat="server" ButtonAlign="Right" Height="185" Padding="5"
Title="Title" Width="300">
<FieldDefaults LabelWidth="90" />
<FieldDefaults ReadOnly="true" />
<Items>
<ext:NumberField ID="NumberField1" runat="server" MinValue="0" >
</ext:NumberField>
<ext:TextField ID="TextField1" runat="server" >
</ext:TextField>
</Items>
<Buttons>
<ext:Button ID="Button1" runat="server" Icon="Disk" Text="Enable Field">
<Listeners>
<Click Handler="enableField();" />
</Listeners>
</ext:Button>
<ext:Button ID="Button2" runat="server" Icon="Disk" Text="Show Value">
<Listeners>
<Click Handler="showValue();" />
</Listeners>
</ext:Button>
</Buttons>

</ext:FormPanel>

</form>
<script type="text/javascript" >

function enableField() {
App.NumberField1.setReadOnly(false);
App.NumberField1.setValue(0);
}
function showValue() {
Ext.Msg.show({
title: 'Value',
msg: App.NumberField1.getValue(),
buttons: Ext.Msg.OK,
icon: Ext.Msg.QUESTION
});
}

</script>
</body>
</html>


Thanks
Aurelio

Daniil
Mar 22, 2012, 7:37 AM
Please keep one issue per one thread. So, please start a new forum thread.

Aurelio
Mar 22, 2012, 11:48 AM
Hi, Daniil... ok

Thanks