[CLOSED] Refresh open RowExpander GridPanel without closing and opening again

  1. #1

    [CLOSED] Refresh open RowExpander GridPanel without closing and opening again

    Hi

    I have a RowExpander with a GridPanel and I want to be able to open the RowExpander, make a change to the parent record and refresh the RowExpander without having to open and close the RowExpander. I've tried many things but I can't get hold of the RowExpander GridPanel's store iin order to reload it.

    In this example:

    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
        @{
        Layout = "~/Views/Shared/_Layout.cshtml";
        }
        @section scripts
        {
            <script>
                var edit = function (editor, e) {
                    if (!(e.value === e.originalValue || (Ext.isDate(e.value) && Ext.Date.isEqual(e.value, e.originalValue)))) {
                        if (e.field == "Name") {
                        }
                    }
            };
            </script>
        }
    </head>
    <body>
    @section mainBody
    {
        @(Html.X().GridPanel().Width(352)
            .Title("Users").ID("GridPanel").Border(true)
            .Store(Html.X().Store()
                .ID("Store")
                .Model(Html.X().Model().IDProperty("ID")
                    .Fields(
                        new ModelField("ID", ModelFieldType.Int),
                        new ModelField("Name"),
                        new ModelField("Test")
                        )
                    )
                .Proxy(Html.X().AjaxProxy().Url(Url.Action("Read")).Reader(Html.X().JsonReader().RootProperty("data"))))
            .ColumnModel(
                Html.X().Column().Text("User").DataIndex("Name").Width(100).Editor(Html.X().TextField()),
                Html.X().Column().Text("Test").DataIndex("Test").Flex(50)
            )
            .SelectionModel(Html.X().RowSelectionModel().ID("rowSelectionModel").Mode(SelectionMode.Single))
            .Plugins(
            Html.X().CellEditing().ClicksToEdit(1).Listeners(ls => ls.Edit.Fn = "edit"),
            Html.X().RowExpander().SingleExpand(true).ID("RowExpand")
            .Component(
                Html.X().GridPanel().Border(true).Height(250).ID("AccessgridPanel")
                    .Store(Html.X().Store().ID("RowExpanderStore")
                        .Model(Html.X().Model()
                            .Fields(
                                new ModelField("Option"),
                                new ModelField("IsReadOnly", ModelFieldType.Boolean)
                                )
                            )
                        .Proxy(Html.X().AjaxProxy().Url(Url.Action("RowExpander")).Reader(Html.X().JsonReader().RootProperty("data")))
                        .AutoLoadParams(new { name = JRawValue.From("this.record.data.Name") }))
                    .ColumnModel(
                        Html.X().Column().Text("Option").DataIndex("Option").Flex(1),
                        Html.X().CheckColumn().Text("Read Only?").DataIndex("IsReadOnly").Width(100).Editable(true)
                    )
                )
                                                    
            )
        )
    }
    </body>
    </html>
    using Ext.Net;
    using Ext.Net.MVC;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web.Mvc;
    
    namespace ExtSandpit.Controllers
    {
        public class HomeController : Controller
        {
            public ActionResult Index()
            {
                return View();
            }
            public ActionResult Read()
            {
                List<User> lstUsers = new List<User>();
                lstUsers.Add(new User(1000,"Jeff"));
                lstUsers.Add(new User(1001,"James"));
                return this.Store(lstUsers);
            }
            public ActionResult RowExpander(string name)
            {
                List<AccessOptionDetail> lstAccessOptionDetail = new List<AccessOptionDetail>();
                if (name == "Jeff")
                {
                    lstAccessOptionDetail.Add(new AccessOptionDetail(1, "Goods In", true));
                }
                else if (name == "James")
                {
                    lstAccessOptionDetail.Add(new AccessOptionDetail(2, "Production", false));
                }
                else if (name == "Chris")
                {
                    lstAccessOptionDetail.Add(new AccessOptionDetail(1, "Goods In", true));
                    lstAccessOptionDetail.Add(new AccessOptionDetail(2, "Production", false));
                }
                return this.Store(lstAccessOptionDetail);
            }
        }
    
        public class User
        {
            public User()
            {
            }
            public User(int id, string name)
            {
                ID = id;
                Name = name;
            }
            public int ID { get; set; }
            public string Name { get; set; }
            public string Test { get; set; }
        }
        public class AccessOptionDetail
        {
            public AccessOptionDetail()
            {
            }
            public AccessOptionDetail(int id, string option, bool isreadonly)
            {
                ID = id;
                Option = option;
                IsReadOnly = isreadonly;
            }
            public int ID { get; set; }
            public string Option { get; set; }
            public bool? IsReadOnly { get; set; }
        }
    }
    I want to be able to:

    • open the RowExpander for the 'Jeff' record


    • change 'Jeff' to 'Chris'


    • see the GridPanel contents change


    I'm sure there's an easy way to do it but...

    Thanks

    Jeff
    Last edited by Daniil; Sep 15, 2015 at 7:19 AM. Reason: [CLOSED]
  2. #2
    Hi Jeff,

    Please use:
    var edit = function (editor, e) {
        var innerGrid;
    
        if (!(e.value === e.originalValue || (Ext.isDate(e.value) && Ext.Date.isEqual(e.value, e.originalValue)))) {
            if (e.field === "Name") {
                innerGrid = e.grid.getRowExpander().getComponent(e.record);
    
                if (innerGrid) { // It means that the edited row is expanded.
                    innerGrid.getStore().reload({
                        params: {
                            name: e.value
                        }
                    });
                }
            }
        }
    };
  3. #3
    Hi Daniil

    That's exactly what I was looking for! Thanks very much for your prompt response.

    Thanks again

    Jeff

Similar Threads

  1. Replies: 3
    Last Post: Sep 11, 2015, 1:19 PM
  2. [CLOSED] can not refresh data in a gridpanel inside rowexpander
    By Fahd in forum 2.x Legacy Premium Help
    Replies: 21
    Last Post: Sep 27, 2013, 5:40 PM
  3. Replies: 6
    Last Post: Apr 03, 2012, 1:54 PM
  4. [CLOSED] Refresh Rowexpander's GridPanel
    By SouthDeveloper in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Jul 21, 2011, 9:28 PM
  5. Replies: 1
    Last Post: Oct 06, 2009, 10:58 AM

Tags for this Thread

Posting Permissions