Sep 17, 2015, 1:53 PM
[3.2.1] Ext.Net.Mvc Store. Various interpretations enum values
Hello,
StoreFor creates model when enum property is interpreted as number but in StoreResult and Store.Data returns enum values as strings.
Please, unify this.
View:
StoreFor creates model when enum property is interpreted as number but in StoreResult and Store.Data returns enum values as strings.
Please, unify this.
View:
@using Ext.Net;
@using Ext.Net.MVC;
@model IEnumerable<ExtNetTest.Test.Models.EnumTestModel>
@{
Layout = null;
var X = Html.X();
}
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
@(Html.X().ResourceManager().Theme(Theme.Neptune))
@(X.GridPanel()
.Title("Using StoreFor(m => m)")
.Width(300)
.Height(200)
.Store(X.StoreFor(m => m))
.ColumnModel(
X.Column().DataIndex("EnumValue").Text("Enum Value")
)
)
@(X.GridPanel()
.Title("Using StoreFor<EnumTestModel>(true) and Data property")
.Width(300)
.Height(200)
.Store(X.StoreFor<ExtNetTest.Test.Models.EnumTestModel>(true)
.Data(Model)
)
.ColumnModel(
X.Column().DataIndex("EnumValue").Text("Enum Value")
)
)
@(X.GridPanel()
.Title("Using StoreFor<EnumTestModel>(true) and Proxy")
.Width(300)
.Height(200)
.Store(X.StoreFor<ExtNetTest.Test.Models.EnumTestModel>(true)
.Proxy(
X.AjaxProxy()
.Url(@Url.Action("GetDataAction"))
.Reader(X.JsonReader().RootProperty("data"))
)
)
.ColumnModel(
X.Column().DataIndex("EnumValue").Text("Enum Value")
)
)
@(X.GridPanel()
.Title("Using StoreFor(m => m) and Proxy.")
.Width(300)
.Height(200)
.TopBar(X.Toolbar()
.Items(
X.Label().Text("Click Refresh button to reload data -> "),
X.Button()
.Text("Refresh")
.Handler("this.up('grid').getStore().load();")
)
)
.Store(X.StoreFor(m => m)
.AutoLoad(false)
.Proxy(
X.AjaxProxy()
.Url(@Url.Action("GetDataAction"))
.Reader(X.JsonReader().RootProperty("data"))
)
)
.ColumnModel(
X.Column().DataIndex("EnumValue").Text("Enum Value")
)
)
</body>
</html>
Controller:using System.Web.Mvc;
using Ext.Net;
using Ext.Net.MVC;
using ExtNetTest.Test.Models;
using System.Collections.Generic;
namespace ExtNet.Test.Controllers
{
public class ExtNetController : Controller
{
private IList<EnumTestModel> GetData()
{
return new List<EnumTestModel>()
{
new EnumTestModel { EnumValue = TestEnum.EnumValue1 },
new EnumTestModel { EnumValue = TestEnum.EnumValue2 }
};
}
public ActionResult Index()
{
return this.View(GetData());
}
public ActionResult GetDataAction()
{
return this.Store(GetData());
}
}
}
Modelusing Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ExtNetTest.Test.Models
{
public enum TestEnum
{
EnumValue1,
EnumValue2
}
public class EnumTestModel
{
public TestEnum EnumValue { get; set; }
}
}