Feb 28, 2013, 8:05 PM
[CLOSED] Load store using parameter to filter data
I have a gridpanel that I want to load the store based on the selection of another control. I have a SelectionChange listener on the other control, and when it fires I call the following script:
Thanks!
var loadStore: function (cid) {
App.LeaderboardStore.reload({ challengeId: cid });
}
Here is the gridpanel:Html.X().GridPanel()
.ID("LeaderboardGrid")
.Header(false)
.Border(false)
.Store(Html.X().Store()
.ID("LeaderboardStore")
.AutoLoad(false)
.Proxy(
Html.X().AjaxProxy()
.Url(Url.Action("GetLeaderBoard"))
.ActionMethods(action =>
{
action.Read = HttpMethod.POST;
})
.Reader(
Html.X().JsonReader().Root("result")
)
)
.Parameters(p =>
{
p.Add(new StoreParameter("challengeId", ""));
})
.Model(
Html.X().Model()
.Fields(
new ModelField("Place"),
new ModelField("Player"),
new ModelField("Points"),
new ModelField("Movement")
)
)
)
And the controller action:[HttpPost]
public ActionResult GetLeaderboard()
{
int challengeId = ?????
Challenge challenge = context.Challenges.Single(c => c.ChallengeId == challengeId);
return new DirectResult((from lb in context.CurrentLeaderBoards
....
}
The script is working and trying to load the store, but I get an error where I'm trying to get the challengeId that I hope the script is passing to the controller. Can someone point me in the right direction?Thanks!