Feb 03, 2017, 1:27 PM
Using Automatic model generation from a class inside of a C# class rather than a razor file
I am writing a lot of my UI declarations inside of C# classes because I really don't like the large razor files and the broken formatting. I like the reusability of this C# based UI classes, too.
I know in razor you can do Html.X().StoreFor<Foo>();
How would you do this in a plain C# class instead of writing an explicit model like this:
And I have the same question for FormPanelForModel<Foo>()...
I know in razor you can do Html.X().StoreFor<Foo>();
How would you do this in a plain C# class instead of writing an explicit model like this:
protected static ext.Model BuildModel()
{
return new ext.Model()
{
ID = "model",
IDProperty = "SupplierID",
Fields =
{
new ext.ModelField("SupplierID",ModelFieldType.Int),
new ext.ModelField("CompanyName"),
new ext.ModelField("ContactName"),
new ext.ModelField("ContactTitle"),
new ext.ModelField("Address"),
new ext.ModelField("City"),
new ext.ModelField("Region"),
new ext.ModelField("PostalCode"),
new ext.ModelField("Country"),
new ext.ModelField("Phone"),
new ext.ModelField("Fax")
}
};
}
My confusion is that Html.X().StoreFor<Foo> returns a Builder which is really for razor declarations. I would like it to return the actual model class kind of like this: protected static ext.Panel BuildTopPanel()
{
return new ext.Panel()
{
ID = "panel",
Region = ext.Region.North,
Border = false,
Height = 120,
BodyPadding = 6,
Html = "<h1>CRUD Grid Example</h1>" +
"<p>Demonstrates how to get data from HttpHandler and save using HttpHandler.</p>"
};
}
And I have the same question for FormPanelForModel<Foo>()...
Last edited by tolgaerdogus; Feb 03, 2017 at 1:34 PM.