PDA

View Full Version : [CLOSED] RadioGroup with dynamic visibility items



softmachine2011
Jul 26, 2013, 8:37 AM
Hi,

I'm trying to change visibility of items in radiogroup.
In Ext.Net V1.3, I have this code:



<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<title>RadioButtonGroup</title>
<ext:ResourcePlaceHolder ID="ResourcePlaceHolder1" runat="server" />
<script type="text/javascript">
function itemsVisible() {
Field1.setVisible(false);
Field3.setVisible(false);
};
</script>
</head>
<body>
<ext:ResourceManager ID="resManager" runat="server" />
<ext:Window ID="window1" runat="server" Modal="true" Width="320" Height="260" MinWidth="320"
MinHeight="260" Border="false" Resizable="false" Constrain="true"
BodyPadding="10">
<Items>
<ext:FieldSet ID="FieldSet1" runat="server" Title="FieldSet" Layout="FitLayout">
<Items>
<ext:RadioGroup ID="RadioGroup1" runat="server" ColumnsNumber="2">
<Items>
<ext:Radio ID="Field1" runat="server" BoxLabel="Field1" Checked="true" />
<ext:Radio ID="Field2" runat="server" BoxLabel="Field2" />
<ext:Radio ID="Field3" runat="server" BoxLabel="Field3" />
<ext:Radio ID="Field4" runat="server" BoxLabel="Field4" />
</Items>
</ext:RadioGroup>
</Items>
</ext:FieldSet>
</Items>
<Listeners>
<Show Handler="itemsVisible();" />
</Listeners>
</ext:Window>
</body>
</html>


When I migrate to V2.1r4377 via SVN the same code produces different result when I set hide/visible any item.

Here is the code in V2.1 r4377


<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<title>RadioButtonGroup</title>
<ext:ResourcePlaceHolder ID="ResourcePlaceHolder1" runat="server" />
<script type="text/javascript">
function itemsVisible() {
App.Field1.setVisible(false);
App.Field3.setVisible(false);
};
</script>
</head>
<body>
<ext:ResourceManager ID="resManager" runat="server" />
<ext:Window ID="window1" runat="server" Hidden="true" Modal="true" Width="320" Height="260" MinWidth="320"
MinHeight="260" Border="false" Resizable="false" Constrain="true"
BodyPadding="10">
<Items>
<ext:FieldSet ID="FieldSet1" runat="server" Title="FieldSet" Layout="FitLayout">
<Items>
<ext:RadioGroup ID="RadioGroup1" runat="server" ColumnsNumber="2">
<Items>
<ext:Radio ID="Field1" runat="server" BoxLabel="Field1" Checked="true" />
<ext:Radio ID="Field2" runat="server" BoxLabel="Field2" />
<ext:Radio ID="Field3" runat="server" BoxLabel="Field3" />
<ext:Radio ID="Field4" runat="server" BoxLabel="Field4" />
</Items>
</ext:RadioGroup>
</Items>
</ext:FieldSet>
</Items>
<Listeners>
<Show Handler="itemsVisible();" />
<Render Handler="this.show();" />
</Listeners>
</ext:Window>
</body>
</html>


And these are the results:
V1.3
6633

V2.1
6634


I think that radiogroup colum rendering has changed and this makes my screen to show different.

I tried to change column number before render and it worked. But the problem is that I only know the number of fields hidden/visible after radiogroup rendered.

Is there an way to solve it and v2.1 r4377 renders like v1.3?


Thanks

Daniil
Jul 26, 2013, 12:33 PM
Hi @softmachine2011,

It renders such a way even if set up Hidden="true" for the required Radios initially. So, I doubt there is a solution with hiding them after rendering.

I am thinking of this approach.

<ext:RadioGroup ID="RadioGroup1" runat="server" ColumnsNumber="2">
<Bin>
<ext:Radio ID="Field1" runat="server" BoxLabel="Field1" Checked="true" />
<ext:Radio ID="Field2" runat="server" BoxLabel="Field2" />
<ext:Radio ID="Field3" runat="server" BoxLabel="Field3" />
<ext:Radio ID="Field4" runat="server" BoxLabel="Field4" />
</Bin>
</ext:RadioGroup>


After rendering you could do this:


App.RadioGroup1.add(App.Field1);
App.RadioGroup1.add(App.Field3);


However, could you clarify the following?

But the problem is that I only know the number of fields hidden/visible after radiogroup rendered.

Why can it not be determined before rendering?

Please note that any processing on rendering stage and after slows down the performance. It is a good rule to follow to configure as much as possible before rendering.

softmachine2011
Jul 29, 2013, 1:09 PM
Hi @Daniil,

I need to hide elements afterRender because I have js code in control and I need to specify which controls are shown from another page.
So, I did what you were saying and it works perfectly.

Thanks

Daniil
Jul 29, 2013, 1:45 PM
I need to hide elements afterRender because I have js code in control and I need to specify which controls are shown from another page.


Thank you for clarifying. We would suggest you to review that design when you have a chance.