[CLOSED] GridPanel selection model does not update, after adding record

  1. #1

    [CLOSED] GridPanel selection model does not update, after adding record

    Hi

    I am using row editing plugin in GridPanel, I see a strange behavior...
    When I add a new record, after adding a new record... I cannot select the newly added record. Strange...

    Given is the sample code.
    Please suggest

    Thanks,
    Rajiv Dutt

    
    
    @{
                var storeEmployee = X.Store()
                       .ID("storeEmployee")
                       .AutoLoad(true)
                       .PageSize(5)
                       .RemoteSort(true)
                       .Proxy(X.AjaxProxy().Url(Url.Action("Read")).Reader(X.JsonReader().Root("data")))
                       .Model(X.Model()
                           .Fields(
                            Html.X().ModelField().Name("Id").Mapping("Id"),
                            Html.X().ModelField().Name("Email").Mapping("Email").SortType(Ext.Net.SortTypeMethod.AsUCString),
                            Html.X().ModelField().Name("First").Mapping("First").SortType(Ext.Net.SortTypeMethod.AsUCString),
                            Html.X().ModelField().Name("Last").Mapping("Last"),
                            Html.X().ModelField().Name("Salary").Mapping("Salary")
                        ));
            }
            @(
    Html.X().GridPanel()
                .Border(true)
                .ColumnLines(true)
                .RowLines(true)
                .Cls("grid-sample")
                .ID("gridEmployee")
                .Width(500)
                .Store(storeEmployee)
                .ColumnModel(
                   X.Column().ID("col1").DataIndex("Id").Text("Id").Hidden(false).Width(20).TdCls("first-row"),
                    X.Column().DataIndex("Email").Width(150).Text("Email").Sortable(true).MenuDisabled(true).Draggable(false)
                        .Editor(
                            Html.X().TextField().AllowBlank(false).StandardVtype(ValidationType.Email)
                                .SelectOnFocus(true)
                        ),
                    X.Column().DataIndex("First").Text("First").Sortable(true).MenuDisabled(true).Draggable(false)
                        .Editor(
                            Html.X().TextField().AllowBlank(false).SelectOnFocus(true).Disabled(true)
                        ),
                    X.Column().DataIndex("Last").Text("Last").Sortable(true).MenuDisabled(true).Draggable(false).Disabled(false)
                        .Editor(
                            Html.X().TextField().AllowBlank(false).SelectOnFocus(true).Disabled(false)
                        ),
                    X.Column().DataIndex("Salary").Text("Salary").Sortable(true).MenuDisabled(true).Draggable(false).Disabled(false)
                        .Editor(
                            Html.X().TextField().AllowBlank(false).SelectOnFocus(true).Disabled(false)
                        )
                )
                .SelectionModel(Html.X().CellSelectionModel().AutoDataBind(true).AllowDeselect(true).Clear().EnableKeyNav(true).Listeners(s => s.Select.Handler = "selectMe()"))
                .BottomBar(
                Html.X().PagingToolbar().ID("editList"))
                .Plugins(
                    Html.X().RowEditing().AutoCancel(false).ErrorSummary(false)
                        .DirectEvents(de =>
                        {
                            de.Edit.Before = "return FieldValidation(el,type,action,extraParams,o)";
                            de.Edit.Url = Url.Action("SaveTardingReason");
                            de.Edit.ExtraParams.Add(new Parameter
                            {
                                Name = "data",
                                Value = "getData()",
                                Mode = ParameterMode.Raw,
                                Encode = true
                            });
                            de.Edit.Method = HttpMethod.POST;
                            de.Edit.Success = " Ext.net.Notification.show({ title: 'Update', html: 'Success' });";
                            de.Edit.Failure = " Ext.net.Notification.show({ title: 'Update', html: 'Failed' });";
                            // de.Edit.EventMask.Msg = "Saving...";
                        })
                        .Listeners(l =>
                        {
                            l.CancelEdit.Handler = "if(e.record.phantom){e.store.remove(e.record);} cancelEdit();";
                            //l.ValidateEdit.Handler = "v";
                            l.BeforeEdit.Handler = "beforeEdit();";
                            l.Edit.Handler = "Edit();";
                        })
                )
                .TopBar(
                    Html.X().Toolbar()
                        .Items(
                            Html.X().Button()
                                .Text("Add")
                                .Icon(Icon.Add)
                                .Handler("this.up('grid').store.insert(0, new LoadTestPerson());this.up('grid').store.commitChanges();"),
    
                            Html.X().Button()
                                .ItemID("btnRemove")
                                .Text("Delete")
                                .Icon(Icon.Exclamation)
                                .Handler("this.up('grid').deleteSelected();")
                        )
                )
        )
        <script type="text/javascript">
            var selectedRow = 0;
    
            function LoadTestPerson()
            {
                this.Id = 0;
                this.Email = "";
                this.First = "";
                this.Last = "";
                this.Salary = 0.00;
            }
    
            function selectMe()
            {
                if (App.gridEmployee.getSelectionSubmit().selModel.selected.length > 0)
                {
                    selectedRow = App.gridEmployee.getSelectionSubmit().selModel.selected.items[0].index;
                    //var currentPage = App.store1.currentPage;
                    var pageSize = App.storeEmployee.pageSize;
                    selectedRow = (selectedRow % pageSize);// * currentPage) + (selectedRow - pageSize);
                }
                else
                    selectedRow = 0;
    
                $(".selected-grid-cell").removeClass('selected-grid-cell');
                $(".x-grid-cell-selected").removeClass('x-grid-cell-selected');
                var firstCell = App.gridEmployee.getView().getCell(App.gridEmployee.store.getAt(selectedRow), App.gridEmployee.columns[0]);
                $(firstCell.dom).addClass("selected-grid-cell");
    
                var selectedCell = App.gridEmployee.view.getCellByPosition(App.gridEmployee.getSelectionModel().getCurrentPosition());
                if (selectedCell)
                {
                    selectedCell.addCls('x-grid-cell-selected');
                }
            }
    
            function beforeEdit()
            {
                //switchGridSort(false);
                //switchGridPaging(true);
                App.gridEmployee.getSelectionSubmit().selModel.deselectAll();
                $(".selected-grid-cell").removeClass('selected-grid-cell');
                $(".x-grid-cell-selected").removeClass('x-grid-cell-selected');
                App.gridEmployee.getSelectionModel().setLocked(true);
            }
    
            function GridEditComplete(grid)
            {
                grid.editingPlugin.completeEdit();
            }
    
            function Edit()
            {
                var grid = App.gridEmployee;
                //switchGridSort(true);
                //switchGridPaging(false);
                grid.getSelectionSubmit().selModel.deselectAll();
                grid.getSelectionModel().setLocked(false);
                GridEditComplete(grid);
                grid.getView().focusRow(selectedRow);
                grid.getSelectionModel().select(selectedRow);
                //setSelectedRow(App.gridEmployee);
                //GridEditComplete(grid);
                //grid.getSelectionModel().select(selectedRow);
                //Grid.getSelectionModel().select(selectedRow);
            }
    
            function cancelEdit()
            {
                var grid = App.gridEmployee;
                //switchGridSort(true);
                //switchGridPaging(false);
                grid.getSelectionSubmit().selModel.deselectAll();
                grid.getSelectionModel().setLocked(false);
                //setSelectedRow(App.gridEmployee);
                GridEditComplete(grid);
                grid.getView().focusRow(selectedRow);
                grid.getSelectionModel().select(selectedRow);
                //setSelectedRow(App.gridEmployee);
            }
    
            var FieldValidation = function (el, type, action, extraParams, o)
            {
                if (!App.storeEmployee.isDirty())
                {
                    //selectedRow++;
    
                    var Grid = App.gridEmployee;
                    var GridStore = Grid.store;
    
                    //if (selectedRow >= GridStore.pageSize || selectedRow >= GridStore.data.length)
                    //    selectedRow = 0;
                    Grid.getView().focusRow(selectedRow);
                    Grid.getSelectionModel().select(selectedRow);
    
                    return false;
                }
            }
            function getData()
            {
                return App.storeEmployee.getChangedData();
            }
            Ext.grid.RowEditor.override({
                beforeEdit: function ()
                {
                    var me = this,
                        scrollDelta;
    
                    //if (me.isVisible() && me.errorSummary && !me.autoCancel && me.isDirty()) {
                    if (me.isVisible() && !me.autoCancel && me.isDirty())
                    {
                        scrollDelta = me.getScrollDelta();
                        if (scrollDelta)
                        {
                            me.scrollingViewEl.scrollBy(0, scrollDelta, true)
                        }
                        //me.showToolTip();
                        return false;
                    }
                }
            });
        </script>
        <style type="text/css">
            .selected-grid-cell {
                background-color: #0096FF !important;
            }
    
            .grid-sample .x-grid-cell-selected {
                background-color: #ffffff !important;
                border: #0096ff 1px solid !important;
            }
    
    
                .grid-sample .x-grid-cell-selected:focus {
                    background-color: #0096ff!important;
                }
    
    
            .grid-sample .x-grid-view {
                overflow: hidden !important;
            }
    
            .first-row .x-item-disabled {
                border: 0px !important;
            }
    
            .grid-sample .x-btn-default-small-noicon .x-btn-inner {
                line-height: 18px !important;
            }
    
            .grid-sample .x-grid-cell-inner {
                padding: 3px 6px 4px !important;
            }
    
            .selected-grid-cell {
                background-color: #0096FF !important;
            }
        </style>
    
    
    Controller
    
            public ActionResult Read(StoreRequestParameters parameters)
            {
                return this.Store(TestPerson.PlantsPaging(parameters));
            }
    
    Model
    
        public class TestPerson
        {
            [ModelField(IDProperty = true, UseNull = true)]
            [Field(Ignore = true)]
            public int? Id
            {
                get;
                set;
            }
    
            [EmailValidation]
            [PresenceValidation]
            public string Email
            {
                get;
                set;
            }
    
            [PresenceValidation]
            public string First
            {
                get;
                set;
            }
    
            [PresenceValidation]
            public string Last
            {
                get;
                set;
            }
    
            [PresenceValidation]
            public List<int> countries
            {
                get;
                set;
            }
    
            private static int curId = 7;
            private static object lockObj = new object();
    
            private static int NewId
            {
                get
                {
                    return System.Threading.Interlocked.Increment(ref curId);
                }
            }
    
            public static List<TestPerson> TestData
            {
                get
                {
                    return new List<TestPerson>
                   {
                       new TestPerson{Id=1, Email="fred@flintstone.com", First="Fred", Last="Flintstone", countries= new List<int>(){1,2}},
                       new TestPerson{Id=2, Email="wilma@flintstone.com", First="Wilma", Last="Flintstone", countries= new List<int>(){2,3}},
                       new TestPerson{Id=3, Email="pebbles@flintstone.com", First="Pebbles", Last="Flintstone", countries= new List<int>(){1,4,5}},
                       new TestPerson{Id=4, Email="barney@rubble.com", First="Barney", Last="Rubble", countries= new List<int>(){2}},
                       new TestPerson{Id=5, Email="betty@rubble.com", First="Betty", Last="Rubble", countries= new List<int>(){4}},
                       new TestPerson{Id=6, Email="bambam@rubble.com", First="BamBam", Last="Rubble", countries= new List<int>(){5,1,4}},
                       new TestPerson{Id=7, Email="pebbles@flintstone.com", First="Pebbles", Last="Flintstone", countries= new List<int>(){2,1}},
                       new TestPerson{Id=8, Email="barney@rubble.com", First="Barney", Last="Rubble", countries= new List<int>(){3}},
                       new TestPerson{Id=9, Email="betty@rubble.com", First="Betty", Last="Rubble", countries= new List<int>(){2,5}},
                       new TestPerson{Id=10, Email="bambam@rubble.com", First="BamBam", Last="Rubble", countries= new List<int>(){5,4,2}}
                   };
                }
    
            }
    
            public static List<TestPerson> Storage
            {
                get
                {
                    var persons = HttpContext.Current.Session["TestPersons"];
    
                    if (persons == null)
                    {
                        persons = TestPerson.TestData;
                        HttpContext.Current.Session["TestPersons"] = persons;
                    }
    
                    return (List<TestPerson>)persons;
                }
                set
                {
                    HttpContext.Current.Session["TestPersons"] = value;
                }
            }
    
            public static void Clear1()
            {
                TestPerson.Storage = null;
            }
    
    
            public static Paging<TestPerson> PlantsPaging(StoreRequestParameters parameters)
            {
                return TestPerson.PlantsPaging(parameters.Start, parameters.Limit, parameters.SimpleSort, parameters.SimpleSortDirection, null);
            }
    
            public static Paging<TestPerson> PlantsPaging(int start, int limit, string sort, SortDirection dir, string filter)
            {
                List<TestPerson> plants = TestPerson.Storage;
                var pagedPersons = plants.Skip(start).Take(limit).ToList();
    
                return new Paging<TestPerson>(pagedPersons, 10);
            }
        }
    Last edited by Daniil; May 28, 2014 at 4:24 AM. Reason: [CLOSED]
  2. #2
    Hi @RajivDutt,

    You create all records with the same Id.
    this.Id = 0;
    But you use Id as IDProperty. It must be unique.
  3. #3
    Hi @Daniil,

    Quote Originally Posted by Daniil View Post
    Hi @RajivDutt,

    You create all records with the same Id.
    this.Id = 0;
    But you use Id as IDProperty. It must be unique.
    Please find the updated code:

    
    @{
                var storeEmployee = X.Store()
                       .ID("storeEmployee")
                       .AutoLoad(true)
                       .PageSize(5)
                       .RemoteSort(true)
                       .Proxy(X.AjaxProxy().Url(Url.Action("Read")).Reader(X.JsonReader().Root("data")))
                       .Model(X.Model()
                           .Fields(
                            Html.X().ModelField().Name("Id").Mapping("Id"),
                            Html.X().ModelField().Name("Email").Mapping("Email").SortType(Ext.Net.SortTypeMethod.AsUCString),
                            Html.X().ModelField().Name("First").Mapping("First").SortType(Ext.Net.SortTypeMethod.AsUCString),
                            Html.X().ModelField().Name("Last").Mapping("Last"),
                            Html.X().ModelField().Name("Salary").Mapping("Salary")
                        ));
            }
            @(
    Html.X().GridPanel()
                .Border(true)
                .ColumnLines(true)
                .RowLines(true)
                .Cls("grid-sample")
                .ID("gridEmployee")
                .Width(500)
                .Store(storeEmployee)
                .ColumnModel(
                   X.Column().ID("col1").DataIndex("Id").Text("Id").Hidden(false).Width(20).TdCls("first-row"),
                    X.Column().DataIndex("Email").Width(150).Text("Email").Sortable(true).MenuDisabled(true).Draggable(false)
                        .Editor(
                            Html.X().TextField().AllowBlank(false).StandardVtype(ValidationType.Email)
                                .SelectOnFocus(true)
                        ),
                    X.Column().DataIndex("First").Text("First").Sortable(true).MenuDisabled(true).Draggable(false)
                        .Editor(
                            Html.X().TextField().AllowBlank(false).SelectOnFocus(true).Disabled(true)
                        ),
                    X.Column().DataIndex("Last").Text("Last").Sortable(true).MenuDisabled(true).Draggable(false).Disabled(false)
                        .Editor(
                            Html.X().TextField().AllowBlank(false).SelectOnFocus(true).Disabled(false)
                        ),
                    X.Column().DataIndex("Salary").Text("Salary").Sortable(true).MenuDisabled(true).Draggable(false).Disabled(false)
                        .Editor(
                            Html.X().TextField().AllowBlank(false).SelectOnFocus(true).Disabled(false)
                        )
                )
                .SelectionModel(Html.X().CellSelectionModel().AutoDataBind(true).AllowDeselect(true).Clear().EnableKeyNav(true).Listeners(s => s.Select.Handler = "selectMe()"))
                .BottomBar(
                Html.X().PagingToolbar().ID("editList"))
                .Plugins(
                    Html.X().RowEditing().AutoCancel(false).ErrorSummary(false)
                        .DirectEvents(de =>
                        {
                            de.Edit.Before = "return FieldValidation(el,type,action,extraParams,o)";
                            de.Edit.Url = Url.Action("SaveTardingReason");
                            de.Edit.ExtraParams.Add(new Parameter
                            {
                                Name = "data",
                                Value = "getData()",
                                Mode = ParameterMode.Raw,
                                Encode = true
                            });
                            de.Edit.Method = HttpMethod.POST;
                            de.Edit.Success = " Ext.net.Notification.show({ title: 'Update', html: 'Success' });";
                            de.Edit.Failure = " Ext.net.Notification.show({ title: 'Update', html: 'Failed' });";
                            // de.Edit.EventMask.Msg = "Saving...";
                        })
                        .Listeners(l =>
                        {
                            l.CancelEdit.Handler = "if(e.record.phantom){e.store.remove(e.record);} cancelEdit();";
                            //l.ValidateEdit.Handler = "v";
                            l.BeforeEdit.Handler = "beforeEdit();";
                            l.Edit.Handler = "Edit();";
                        })
                )
                .TopBar(
                    Html.X().Toolbar()
                        .Items(
                            Html.X().Button()
                                .Text("Add")
                                .Icon(Icon.Add)
                                .Handler("this.up('grid').store.insert(0, new LoadTestPerson());this.up('grid').store.commitChanges();"),
    
                            Html.X().Button()
                                .ItemID("btnRemove")
                                .Text("Delete")
                                .Icon(Icon.Exclamation)
                                .Handler("this.up('grid').deleteSelected();")
                        )
                )
        )
        <script type="text/javascript">
              var selectedRow = 0;
            var personID = 100;
            function fetchID()
            {
                personID = personID + 1;
                return personID;
            }
    
            function LoadTestPerson()
            {
                this.Id = fetchID();
                this.Email = "";
                this.First = "";
                this.Last = "";
                this.Salary = 0.00;
            }
    
            function selectMe()
            {
                if (App.gridEmployee.getSelectionSubmit().selModel.selected.length > 0)
                {
                    selectedRow = App.gridEmployee.getSelectionSubmit().selModel.selected.items[0].index;
                    //var currentPage = App.store1.currentPage;
                    var pageSize = App.storeEmployee.pageSize;
                    selectedRow = (selectedRow % pageSize);// * currentPage) + (selectedRow - pageSize);
                }
                else
                    selectedRow = 0;
    
                $(".selected-grid-cell").removeClass('selected-grid-cell');
                $(".x-grid-cell-selected").removeClass('x-grid-cell-selected');
                var firstCell = App.gridEmployee.getView().getCell(App.gridEmployee.store.getAt(selectedRow), App.gridEmployee.columns[0]);
                $(firstCell.dom).addClass("selected-grid-cell");
    
                var selectedCell = App.gridEmployee.view.getCellByPosition(App.gridEmployee.getSelectionModel().getCurrentPosition());
                if (selectedCell)
                {
                    selectedCell.addCls('x-grid-cell-selected');
                }
            }
    
            function beforeEdit()
            {
                //switchGridSort(false);
                //switchGridPaging(true);
                App.gridEmployee.getSelectionSubmit().selModel.deselectAll();
                $(".selected-grid-cell").removeClass('selected-grid-cell');
                $(".x-grid-cell-selected").removeClass('x-grid-cell-selected');
                App.gridEmployee.getSelectionModel().setLocked(true);
            }
    
            function GridEditComplete(grid)
            {
                grid.editingPlugin.completeEdit();
            }
    
            function Edit()
            {
                var grid = App.gridEmployee;
                //switchGridSort(true);
                //switchGridPaging(false);
                grid.getSelectionSubmit().selModel.deselectAll();
                grid.getSelectionModel().setLocked(false);
                GridEditComplete(grid);
                grid.getView().focusRow(selectedRow);
                grid.getSelectionModel().select(selectedRow);
                //setSelectedRow(App.gridEmployee);
                //GridEditComplete(grid);
                //grid.getSelectionModel().select(selectedRow);
                //Grid.getSelectionModel().select(selectedRow);
            }
    
            function cancelEdit()
            {
                var grid = App.gridEmployee;
                //switchGridSort(true);
                //switchGridPaging(false);
                grid.getSelectionSubmit().selModel.deselectAll();
                grid.getSelectionModel().setLocked(false);
                //setSelectedRow(App.gridEmployee);
                GridEditComplete(grid);
                grid.getView().focusRow(selectedRow);
                grid.getSelectionModel().select(selectedRow);
                //setSelectedRow(App.gridEmployee);
            }
    
            var FieldValidation = function (el, type, action, extraParams, o)
            {
                if (!App.storeEmployee.isDirty())
                {
                    //selectedRow++;
    
                    var Grid = App.gridEmployee;
                    var GridStore = Grid.store;
    
                    //if (selectedRow >= GridStore.pageSize || selectedRow >= GridStore.data.length)
                    //    selectedRow = 0;
                    Grid.getView().focusRow(selectedRow);
                    Grid.getSelectionModel().select(selectedRow);
    
                    return false;
                }
            }
            function getData()
            {
                return App.storeEmployee.getChangedData();
            }
            Ext.grid.RowEditor.override({
                beforeEdit: function ()
                {
                    var me = this,
                        scrollDelta;
    
                    //if (me.isVisible() && me.errorSummary && !me.autoCancel && me.isDirty()) {
                    if (me.isVisible() && !me.autoCancel && me.isDirty())
                    {
                        scrollDelta = me.getScrollDelta();
                        if (scrollDelta)
                        {
                            me.scrollingViewEl.scrollBy(0, scrollDelta, true)
                        }
                        //me.showToolTip();
                        return false;
                    }
                }
            });
        </script>
        <style type="text/css">
            .selected-grid-cell {
                background-color: #0096FF !important;
            }
    
            .grid-sample .x-grid-cell-selected {
                background-color: #ffffff !important;
                border: #0096ff 1px solid !important;
            }
    
    
                .grid-sample .x-grid-cell-selected:focus {
                    background-color: #0096ff!important;
                }
    
    
            .grid-sample .x-grid-view {
                overflow: hidden !important;
            }
    
            .first-row .x-item-disabled {
                border: 0px !important;
            }
    
            .grid-sample .x-btn-default-small-noicon .x-btn-inner {
                line-height: 18px !important;
            }
    
            .grid-sample .x-grid-cell-inner {
                padding: 3px 6px 4px !important;
            }
    
            .selected-grid-cell {
                background-color: #0096FF !important;
            }
        </style>
    
    
    Controller
    
            public ActionResult Read(StoreRequestParameters parameters)
            {
                return this.Store(TestPerson.PlantsPaging(parameters));
            }
    
    Model
    
        public class TestPerson
        {
            [ModelField(IDProperty = true, UseNull = true)]
            [Field(Ignore = true)]
            public int? Id
            {
                get;
                set;
            }
    
            [EmailValidation]
            [PresenceValidation]
            public string Email
            {
                get;
                set;
            }
    
            [PresenceValidation]
            public string First
            {
                get;
                set;
            }
    
            [PresenceValidation]
            public string Last
            {
                get;
                set;
            }
    
            [PresenceValidation]
            public List<int> countries
            {
                get;
                set;
            }
    
            private static int curId = 7;
            private static object lockObj = new object();
    
            private static int NewId
            {
                get
                {
                    return System.Threading.Interlocked.Increment(ref curId);
                }
            }
    
            public static List<TestPerson> TestData
            {
                get
                {
                    return new List<TestPerson>
                   {
                       new TestPerson{Id=1, Email="fred@flintstone.com", First="Fred", Last="Flintstone", countries= new List<int>(){1,2}},
                       new TestPerson{Id=2, Email="wilma@flintstone.com", First="Wilma", Last="Flintstone", countries= new List<int>(){2,3}},
                       new TestPerson{Id=3, Email="pebbles@flintstone.com", First="Pebbles", Last="Flintstone", countries= new List<int>(){1,4,5}},
                       new TestPerson{Id=4, Email="barney@rubble.com", First="Barney", Last="Rubble", countries= new List<int>(){2}},
                       new TestPerson{Id=5, Email="betty@rubble.com", First="Betty", Last="Rubble", countries= new List<int>(){4}},
                       new TestPerson{Id=6, Email="bambam@rubble.com", First="BamBam", Last="Rubble", countries= new List<int>(){5,1,4}},
                       new TestPerson{Id=7, Email="pebbles@flintstone.com", First="Pebbles", Last="Flintstone", countries= new List<int>(){2,1}},
                       new TestPerson{Id=8, Email="barney@rubble.com", First="Barney", Last="Rubble", countries= new List<int>(){3}},
                       new TestPerson{Id=9, Email="betty@rubble.com", First="Betty", Last="Rubble", countries= new List<int>(){2,5}},
                       new TestPerson{Id=10, Email="bambam@rubble.com", First="BamBam", Last="Rubble", countries= new List<int>(){5,4,2}}
                   };
                }
    
            }
    
            public static List<TestPerson> Storage
            {
                get
                {
                    var persons = HttpContext.Current.Session["TestPersons"];
    
                    if (persons == null)
                    {
                        persons = TestPerson.TestData;
                        HttpContext.Current.Session["TestPersons"] = persons;
                    }
    
                    return (List<TestPerson>)persons;
                }
                set
                {
                    HttpContext.Current.Session["TestPersons"] = value;
                }
            }
    
            public static void Clear1()
            {
                TestPerson.Storage = null;
            }
    
    
            public static Paging<TestPerson> PlantsPaging(StoreRequestParameters parameters)
            {
                return TestPerson.PlantsPaging(parameters.Start, parameters.Limit, parameters.SimpleSort, parameters.SimpleSortDirection, null);
            }
    
            public static Paging<TestPerson> PlantsPaging(int start, int limit, string sort, SortDirection dir, string filter)
            {
                List<TestPerson> plants = TestPerson.Storage;
                var pagedPersons = plants.Skip(start).Take(limit).ToList();
    
                return new Paging<TestPerson>(pagedPersons, 10);
            }
        }
  4. #4
    A JavaScript occurs in the selectMe method. If you debug it, you would see that "selectedRow" is NaN for a new row.

    I think the problem is here.
    selectedRow = App.gridEmployee.getSelectionSubmit().selModel.selected.items[0].index;
    Please try
    selectedRow = App.gridEmployee.getStore().indexOf(App.gridEmployee.getSelectionSubmit().selModel.selected.items[0]);
    In the future please don't rely on a record's index property.

Similar Threads

  1. Replies: 2
    Last Post: Apr 21, 2014, 8:24 AM
  2. Replies: 1
    Last Post: Dec 04, 2013, 10:53 AM
  3. Replies: 3
    Last Post: Oct 05, 2012, 11:44 AM
  4. Replies: 10
    Last Post: Nov 01, 2010, 11:33 AM
  5. [CLOSED] Gridpanel selection model
    By drgw74 in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 14, 2009, 9:52 AM

Posting Permissions