PDA

View Full Version : [CLOSED] GetCmp-Trouble when tabpanel not initialized



tMp
Jul 22, 2014, 7:41 AM
Hi

I the test case please set a debug toggle point on saveText, run it, press edit - don't switch to the second tab - save it and take a look at the two test strings. String test is ok, but string test2 has null. Why so? Has this something to do with the tab no been initialized? Can I force it to initialize?

thank you very much for your insight.

best regards,

T

sorry about the quick 'n dirty code...

<%@ 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)
{

}
}


[DirectMethod]
public static void saveText(string textOne, string textTwo)
{
string test = textTwo;

string test2 = X.GetCmp<TextArea>("txtTextTwo").Text;
}

[DirectMethod]
public static void editText(string textOne, string textTwo)
{
Window win = new Window
{
ID = "wEdit",
Title = "edit text",
Width = 500,
ManageHeight = true,
Modal = true,
CloseAction = Ext.Net.CloseAction.Destroy,
BodyStyle = "background-color: #fff;",
Items =
{
new TabPanel {
MinTabWidth = 150,
ManageHeight = true,
Border = false,
Items = {
new Ext.Net.Panel {
Title = "text one",
Border = false,
Padding = 5,
Layout = "Form",
DefaultAnchor = "100%",
Items = {
new TextArea {
ID = "txtTextOne",
Height = 100, AutoScroll = true,
Text = textOne
}
}
},
new Ext.Net.Panel {
Title = "text two",
Border = false,
BodyPadding = 5,
Layout = "Form",
DefaultAnchor = "100%",
Items = {
new TextArea { ID = "txtTextTwo",
Height = 100,
AutoScroll = true,
Text = textTwo
}
}
}
}
},
new Ext.Net.Button {
Text = "Save",
Listeners = {
Click = { Handler = "App.direct.saveText(#{txtTextOne}.getValue(), #{txtTextTwo}.getValue());" }
}
}
}
};

win.Render();
}

</script>

<!DOCTYPE html>

<html>
<head id="Head" runat="server">
<title></title>

</head>
<body>
<form id="Form" runat="server">
<ext:ResourceManager ID="ResourceManager" runat="server" Locale="de-CH" />

<ext:TextField runat="server" ID="textfOne" FieldLabel="Text One" Disabled="true" Text="one"></ext:TextField>
<ext:TextField runat="server" ID="textfTwo" FieldLabel="Text Two" Disabled="true" Text="two"></ext:TextField>
<ext:Button runat="server" ID="editButton" Text="edit" OnClientClick="App.direct.editText(#{textfOne}.getValue(), #{textfTwo}.getValue());" Width="100"></ext:Button>

</form>
</body>
</html>

Daniil
Jul 22, 2014, 12:51 PM
Hi @tMp,


Has this something to do with the tab no been initialized?

Yes, you are right. The second tab is not active, it means that it is not rendered. Respectively, it means that its TextArea is not rendered as well and doesn't go to a POST.

But it is not the entire problem in the case with a static DirectMethod. A static DirectMethod doesn't submit a form at all. Please pass any required client info only via parameters.


Can I force it to initialize?

You could by setting this setting for a TabPanel.

DeferredRender="false"
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.tab.Panel-cfg-deferredRender

But, as I said, it won't help in the case with a static DirectMethod.

tMp
Jul 22, 2014, 1:41 PM
Hi @Daniil

So you say the text is there and just the textarea isn't rendered?

Funny that in my actual problem case I can get all the components via GetCmp<> except the ones that are not initialized and I am doing it there via a DirectMethod. I have to look further into that why it is working in that case (I tried it with textOne in the example and it wasn't working like you told me).

I solved my actual problem with the DeferredRenderer = false. (Still using GetCmp and DirectMethod though ;) )

Thanks.

Daniil
Jul 22, 2014, 8:03 PM
So you say the text is there and just the textarea isn't rendered?

I am not sure I understand the question, but yes, the text is there, in the TextArea JavaScript class. But it is not submitted to server, because the TextArea is not rendered.


I tried it with textOne in the example and it wasn't working like you told me

Do you mean that this code returns actual text of the txtTextOne TextArea?

X.GetCmp<TextArea>("txtTextOne").Text

Could you, please, provide an exact sample that would demonstrate it is working?

By the way, what Ext.NET version are you using?

tMp
Jul 23, 2014, 7:28 PM
Hi @Daniil,

I will try to look into it this weekend... Will get back to you asap.

best regards!

tMp
Jul 27, 2014, 1:41 PM
Hi @Daniil,

I can't reproduce it when doing a single file example and building it from bottom up. I will have to strip down my whole web application to isolate the specific function. But yeah I don't now what I have done differentliy but that is excatly what I am saying.

My Ext.Net Version is 2.5.1.31696

Daniil
Jul 29, 2014, 6:40 PM
Thank you for the attempt. Well, you are free not to waste your time on that anymore, if you wish:)