[CLOSED] Load store using parameter to filter data

  1. #1

    [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:

    var loadStore: function (cid) {
        App.LeaderboardStore.reload({ challengeId: cid });
    Here is the gridpanel:
                  .ActionMethods(action =>
                      action.Read = HttpMethod.POST;
          .Parameters(p =>
              p.Add(new StoreParameter("challengeId", ""));
                      new ModelField("Place"),
                      new ModelField("Player"),
                      new ModelField("Points"),
                      new ModelField("Movement")
    And the controller action:
    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?

  2. #2

    Try the following:
        params: {
            challengeId: cid
    You should use correct syntax for the option of reload method

  3. #3
    Thanks Baidaly ... I updated the syntax in the js.

    But - how do I get the parameter value in my controller action? I have tried several variations:

    public ActionResult GetLeaderboard(StoreParameter param)
    public ActionResult GetLeaderboard(int challengeId)
    public ActionResult GetLeaderboard()
         int challengeId = Int32.Parse(X.GetCmp<Store>("LeaderboardStore").Parameters["challengeId"].ToString());
    All of these end up with a null value or object not found.
  4. #4
    Also tried this:

    public ActionResult GetLeaderboard(StoreParameterCollection parms)
         int challengeId = Int32.Parse(parms["challengeId"].ToString());
  5. #5
    What value is contained in 'cid'?

    public ActionResult GetLeaderboard(int challengeId)
    this code should work correctly if cid is number

    Please post runable sample demonstrates the issue
    Also try to remove this
    .Parameters(p =>
              p.Add(new StoreParameter("challengeId", ""));
    Vladimir Shcheglov
    Sr. Developer
  6. #6
    Vladimir - 'cid' is an integer, and removing the parameter worked!

    Also try to remove this
    .Parameters(p =>
    p.Add(new StoreParameter("challengeId", ""));
    I am using:
    App.LeaderboardStore.reload({ params: { challengeId: cid } });
    public ActionResult GetLeaderboard(int challengeId)
    Thank you!

Similar Threads

  1. Replies: 2
    Last Post: Nov 01, 2012, 7:24 PM
  2. Replies: 6
    Last Post: Jul 15, 2011, 2:03 PM
  3. [CLOSED] HttpProxy sample with Method='GET' to load data for store
    By inayath in forum 1.x Legacy Premium Help
    Replies: 10
    Last Post: Feb 08, 2011, 3:18 PM
  4. Replies: 6
    Last Post: Nov 14, 2010, 3:08 AM
  5. [CLOSED] Ext.data.store.load()
    By RomualdAwessou in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 01, 2010, 11:24 PM

Posting Permissions