Sep 23, 2013, 9:12 PM
[CLOSED] Populating a Form Panel from a DirectMethod
If I have a direct method that just returns an object, like "Customer", and I want to display those values in a FormPanel, can I do it like this:
Thanks!
// C# Code
public class MyType {
public int FirstAttribute {get; set;}
public string SecondAttribute {get; set;}
public MyType(int myParameterID)
{
FirstAttribute = myParameterID;
}
}
//Codebehind
[DirectMethod]
public MyType MyDirectMethod(int myParameterID)
{
MyType myObject = new MyType(myParameterID);
myObject.SecondAttribute = "Just some string";
return MyType;
}
//Javascript
var MyListeners = {
PopulateForm: function() {
var myParameterID = 1;
App.direct.MyDirectMethod(myParameterID, { success: function(myResult) {
App.MyForm.loadRecord(myResult);
}
});
}
}
<ext:FormPanel ID="MyForm" runat="server">
<Items>
<ext:FieldSet runat="server" ID="MyFieldSet">
<Items>
<ext:DisplayField runat="server" ID="NameOfMyDisplayField" DataIndex="MyFirstAttribute" />
<ext:DisplayField runat="server" ID="NameOfMyDisplayField" DataIndex="MySecondAttribute" />
</Items>
</ext:FieldSet>
</Items>
</ext:FormPanel>
<ext:Button ID="DoPopulate" runat="server">
<Listeners>
<Click Fn="MyListeners.PopulateForm" />
</Listeners>
</ext:Button>
I ask because I can't debug inside the JavaScript DirectMethod caller, and I'm not getting the results I expect. Thanks!
Last edited by Daniil; Oct 04, 2013 at 5:51 AM.
Reason: [CLOSED]