Dec 26, 2014, 6:02 PM
[CLOSED] MultiSelect : Load multiselect with proxy not working
Please see bellow with this code store not loaded with proxy.
view
UPDATE
I understand ,I am creating an array of objects here,that is wrong with my code.
can you please help me ,with proper code without create a class and then its list.
UPDATE
I try bellow code and working.please close this.
view
@{
Layout = null;
}
<!DOCTYPE html>
<html>
@{
var X = Html.X();
}
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
<div>
@(X.ResourceManager())
@( X.MultiSelect()
.Height(260)
.ID("MS1")
.Width(300)
.Border(true)
.DisplayField("opText")
.ValueField("opValue")
.MaxSelections(1)
.SingleSelect(true)
.Listeners(l =>
{
l.Change.Handler = @"populateTag(this.getSubmitArray()[0]['value'],this.getSubmitArray()[0]['text'])";
l.AfterRender.Handler = "App.MS1.getStore().reload()";
})
.Store(X.Store()
.ID("StoreMS1")
.Model(X.Model()
.IDProperty("opValue")
.Fields(
Html.X().ModelField().Name("opValue").Type(ModelFieldType.String),
Html.X().ModelField().Name("opText").Type(ModelFieldType.String)
)
)
.AutoLoad(true)
.ServerProxy(X.AjaxProxy()
.Url(Url.Action("Getoperators", "loadmultiselectwithproxy"))
.Reader(X.JsonReader().Root("data"))
)
)
)
</div>
</body>
</html>
Controllerpublic class loadmultiselectwithproxyController : Controller
{
//
// GET: /loadmultiselectwithproxy/
public ActionResult Index()
{
return View();
}
public ActionResult Getoperators()
{
return this.Store(new object[]
{
new object[] { "1", "+" },
new object[] { "2", "-" },
new object[] { "3", "*" },
new object[] { "4", "/" },
new object[] { "5", "%" }
});
}
}
please let me know how do I do this.UPDATE
I understand ,I am creating an array of objects here,that is wrong with my code.
can you please help me ,with proper code without create a class and then its list.
UPDATE
I try bellow code and working.please close this.
public List<dynamic> Getoperators()
{
List<dynamic> data = new List<dynamic>();
data.Add(new { opValue = "1", opText = "+" });
data.Add(new { opValue = "2", opText = "-" });
data.Add(new { opValue = "3", opText = "*" });
data.Add(new { opValue = "4", opText = "/" });
data.Add(new { opValue = "5", opText = "%" });
return data;
}
Last edited by fabricio.murta; Feb 20, 2015 at 2:17 AM.
Reason: [CLOSED]