[CLOSED] How to access/reload store in razor views/controller

  1. #1

    [CLOSED] How to access/reload store in razor views/controller

    Hi there,

    How can I go about rebinding a store in the controller? i.e. how can I access the store in order to do something like:
    this.Store1.DataSource = this.Data;
            this.Store1.DataBind();
    to give you some context - I have a single page with a form panel and a grid panel. The form panel gathers details and then calls into the controller to execute a query and return a collection. I now want the controller method to bind this collection to the store of the grid panel - how can I do this? Do I have to do something like what is above somehow? Or if I convert the collection into a StoreResult and return that, will the view simply handle it? How would this work with multiple stores in a single view?
    Last edited by Daniil; Apr 06, 2012 at 9:59 AM. Reason: Please use [CODE] tags, [CLOSED]
  2. #2
    Hi,

    I would set up HttpProxy for a Store pointing its Url to a respective controller action.

    Then you will be able to reload that Store just calling its reload client side method. It will make a load request to a controller action.
    Store1.reload();
  3. #3
    But how do I pass the parameters from the form panel to that controller method? I have a form panel with a direct event on the submit button which triggers a controller method - i need the response from this method to then be the datasource for the grid panel.
  4. #4
    Quote Originally Posted by machinableed View Post
    I have a form panel with a direct event on the submit button which triggers a controller method
    Please clarify - is it a common DirectEvent with Url or do you submit a FormPanel using its submit method?
  5. #5
    yes it's a standard direct event

    cutdown code:

     pn.Add(Html.X().FormPanel()
                        .Region(Region.North)
                        .Collapsible(true)
                        .Title("Enter Search Criteria")
                        .BodyPadding(4)
                        .Layout(LayoutType.Column)
                        .AutoHeight(true)
                        .Buttons(buttons =>
                        {
                            buttons.Add(Html.X().Button()
                                .DirectEvents(directEvents =>
                                {
                                    //directEvents.Click.
                                    directEvents.Click.Url = "/Services/Clear";
                                })
                                .Text("Clear"));
    
                            buttons.Add(Html.X().Button()
                                .DirectEvents(directEvents =>
                                {
                                    directEvents.Click.Url = "/Services/Search";
                                })
                                .Text("Search"));
    
                        })
    .Items(fields=>
                        {
    //form fields go here.
    })
    pn.Add(Html.X().GridPanel()
                       .Region(Region.South)
                       .Margins("4 0 0 0")
                       .AutoHeight(true)
                       .Title("TEST PANEL")
    .store( 
    //store stuff here
    )
    .columnModel(
    
    )
    Now... on the submit the form successfully submits and ends up in the correct controller method that returns a StoreResult. I want to use this store result to be the datasource for the GridPanel.

    Hope this is clearer...
  6. #6
    Thanks for the clarification.

    StoreResult should be used in a combination with a Store Proxy.

    I can suggest to return an AjaxResult instance from a controller action and pass a data via its ExtraParamsResponse.

    Example
    public ActionResult Submit(/*parameters*/)
    {
        List<object> data = new List<object>()
        {
            new 
            {
                test = "test 1"
            },
            new 
            {
                test = "test 2"
            }
        };
    
        AjaxResult r = new AjaxResult()
        {
            ExtraParamsResponse = 
            {
                new Parameter()
                {
                    Name = "data",
                    Value = JSON.Serialize(data),
                    Mode = ParameterMode.Raw
                }
            }
        };
    
        return r;
    }
    Then you can load that data into the Store within a DirectEvent success handler using the Store loadData method.
    Store1.loadData(result.extraParamsResponse.data);

Similar Threads

  1. [CLOSED] [RAZOR] How to access ext.net controls from controller method
    By gets_gui in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: Sep 13, 2012, 8:12 AM
  2. [CLOSED] [Razor] using partial views
    By machinableed in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 25, 2012, 9:40 AM
  3. [CLOSED] combobox list config not available in razor views
    By machinableed in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 03, 2012, 2:54 PM
  4. [CLOSED] Razor and Ext.Net base and partial views
    By boris in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Mar 01, 2012, 3:45 PM
  5. Access Theme views
    By amitpareek in forum Open Discussions
    Replies: 10
    Last Post: Apr 12, 2010, 5:04 PM

Posting Permissions