May 19, 2015, 6:05 AM
[CLOSED] StoreForModel : Get grid values in controller method as list of object
Hi
I have a question ,I prepare a grid with StoreforModel and try to get grid value on submit button click as list of object in controller action ,Is it possible?
also I found there are no DateColumnFor option ,so how I manage date with Storefor approach?
How I define IdProperty ?
I have a question ,I prepare a grid with StoreforModel and try to get grid value on submit button click as list of object in controller action ,Is it possible?
@model e.Controllers.StoreforModelEmployee
@{
var X=Html.X();
}
<script>
function fullNameBuilder(value, record) {
return record.data.LastName + ', ' + record.data.FirstName;
}
</script>
<h1>Store for Model</h1>
<p>Automatically build store for a model</p>
@Html.X().ResourceManager()
@(
@X.FormPanel()
.ID("f")
.Items
(
Html.X().GridPanel()
.Title("Employees")
.Width(500)
.Height(200)
.ForceFit(true)
.Plugins(X.CellEditing())
.Store(
Html.X().StoreFor<e.Controllers.StoreforModelEmployee>()
)
.ColumnModel(
Html.X().ColumnFor(m => m.Id).ToBuilder<Column.Builder>().Width(30),
Html.X().Column().DataIndex("FullName").Text("Full Name").Editor(X.TextField()),
Html.X().ColumnFor(m => m.FirstName),
Html.X().ColumnFor(m => m.LastName)
)
)
.Buttons(
X.Button()
.Text("Submit")
.DirectEvents(d=>{
d.Click.FormID = "f";
d.Click.Action = "submit";
})
)
)
public class StoreforModelController : Controller
{
//
// GET: /StoreforModel/
public ActionResult Index()
{
return View();
}
public ActionResult GetEmployees()
{
return this.Store(StoreforModelEmployee.GetAll());
}
public void submit(List<StoreforModelEmployee> _StoreforModelEmployee)
{
}
}
[Proxy(Read = "~/StoreforModel/GetEmployees")]
[JsonReader(Root = "data")]
[VirtualModelField(Name = "FullName", ConvertHandler = "fullNameBuilder")]
// [ClientResource(Path = "~/Areas/Models/Content/storeHelpers.js")]
public class StoreforModelEmployee
{
[ModelField(IDProperty = true)]
public int Id
{
get;
set;
}
public string FirstName
{
get;
set;
}
public string LastName
{
get;
set;
}
[ModelField(Ignore = true)]
public string IgnoreField
{
get;
set;
}
public static List<StoreforModelEmployee> GetAll()
{
return new List<StoreforModelEmployee> {
new StoreforModelEmployee{ Id = 1, FirstName = "John", LastName = "Snow"},
new StoreforModelEmployee{ Id = 2, FirstName = "Fred", LastName = "Flintstone"},
new StoreforModelEmployee{ Id = 3, FirstName = "Andrew", LastName = "Fuller"}
};
}
}
I need the list in submit
method as parameter.also I found there are no DateColumnFor option ,so how I manage date with Storefor approach?
How I define IdProperty ?
Last edited by Daniil; May 26, 2015 at 4:50 PM.
Reason: [CLOSED]