[CLOSED] [RAZOR] Change the store on a GridPanel

  1. #1

    [CLOSED] [RAZOR] Change the store on a GridPanel

    Hi

    I have a store defined on a GridPanel. Once the user clicks Search I have to change the store's content to the new query.

    I have the following razor code, a backing controller and a method to make a remote call and return the results as a StoreResult.

    I've followed the link

    http://forums.ext.net/showthread.php...ews-controller

    But I'm not sure how to get a handle to the store to call .LoadData(...)

        
          .Add(Html.X().Panel()
                .ID("Summary")
                .Title("Summary")
                .Split(true)
                .Layout(Ext.Net.LayoutType.Accordion)
                .Add(Html.X().Panel()
                    .ID("Panel1")
                    .Title("Summary")
                    .Add(Html.X().GridPanel()
                        .ID("SummaryGridPanel")                   
                        .AutoScroll(true)
                        .ColumnModel(columns =>
                        {
                            columns.Add(Html.X().Column()
                                .Text("Column1")
                                .DataIndex("_Column1")
                            );
                            columns.Add(Html.X().Column()
                                .Text("Column2")
                                .DataIndex("_Column1")
                            );
                        })                    
                        .Store(store => store.Add(Html.X().Store()
                            .ID("SummaryStore")
                            .Buffered(false)
                            .AutoLoad(false)
                            .Proxy(proxy => proxy.Add(Html.X().AjaxProxy()
                            .Url("/Query/GetData")
                                .Reader(reader => reader.Add(Html.X().JsonReader()
                                    .Root("data")
                                ))
                            ))
                            .Model(model => model.Add(Html.X().Model().Fields(fields =>
                            {
                                fields.Add(Html.X().ModelField().Name("_Column1"));
                            })
                        ))
                        ))
                    )
                )
                ...
    Last edited by Daniil; Jul 27, 2012 at 2:04 PM. Reason: [CLOSED]
  2. #2
    Hi,

    You can just call client side:
    store.load({
        params : {
            param1 : 'param1',
            param2 : 'param2'
        }
    });
    It will initiate a load request following the Url you have specified for the AjaxProxy.
  3. #3
    Hi Daniil

    Not sure I understand your reply

    I have the following controller code, GetStore() isn't intialised. From my controller code how do I reload the store?

    
    // Get a reference to the GridPanel
    var ordersGrid = X.GetCmp<GridPanel>("SummaryGridPanel");
    
    // Get the store, this returns null
    var store = ordersGrid.GetStore();
  4. #4
    You should just return a StoreResult instance setting up its Data property. You should not deal with the Store instance.
  5. #5
    Hi Daniil

    Still having issues getting this to work. I've upgrades to 2.0.0 RC-2 which has added the Store object

    My store has a proxy defined on it so I'm using the LoadProxy method to load the results. When running the code I get no results in the grid.

    var store = X.GetCmp<Store>("resultStore");
    
    var results = GetStoreResults();
    
    store.LoadProxy(results);
    An additonal question is if I try and setup a AjaxResult object to to returned I always get an Invalid JSON response. Method returns a ActionResult.

                    r = new AjaxResult()
                    {
                        ExtraParamsResponse = 
                        {    
                            new Parameter() 
                            { 
                                Name = "result",
                                Value = "hello",
                                Mode = ParameterMode.Value
                            }
                        }
                    };
  6. #6
    Ok, lets clarify the requirement.

    1. When do you need to load a new data into the Store?

    2. Can you load that new data from the Url you have defined for the AjaxProxy?
  7. #7
    Hi Daniil

    1) I need to load data into the store once the use clicks a button. This will send a event on the messagebus to a listener/handler I have defined in the controller. In the handler I want to call the method which populates a StoreResult object (Which is correctly populated) and display this on the GridPanel which already has a AjaxProxy defined on it.

    2) Yes, if I set AutoLoad to true. The URI is called and the GridPanel does populate with the correct results.
  8. #8
    Ok, thanks for the clarification.

    When a user clicks the Button, you should call client side the following code:
    store.load({
        url : 'some url' // if you need to use another URL comparing to the AjaxProxy one.
    });
    An action controller should return a StoreResult.

Similar Threads

  1. [CLOSED] [Razor] Add GridView to GridPanel in razor
    By boris in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: May 09, 2012, 4:23 PM
  2. [CLOSED] Change Store Datasource in Combo Editor Column inside GridPanel
    By tlfdesarrollo in forum 1.x Legacy Premium Help
    Replies: 9
    Last Post: Apr 13, 2012, 7:32 PM
  3. Replies: 1
    Last Post: Apr 13, 2012, 3:15 PM
  4. change store data and gridpanel refresh
    By ven in forum 1.x Help
    Replies: 1
    Last Post: Jun 18, 2011, 6:28 AM
  5. Replies: 0
    Last Post: Dec 30, 2010, 1:13 AM

Tags for this Thread

Posting Permissions