[CLOSED] GridPanel Batch Update does not send data

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] GridPanel Batch Update does not send data

    I am using Ext.NET 2.1.1.18233 with Visual Studio 2010 and ASP.NET MVC 4. I am attempting to submit batch changes from a grid panel using a simple button. I have tried various examples and cannot get the grid panel to submit changed records to an MVC controller method. The POST data indicates that an empty JSON object is submitted. The relevant code samples including my model and grid panel are shown below. I have used the following example, and a forum thread for guidance:

    http://mvc.ext.net/#/GridPanel_Update/Batch/

    Much code is omitted for brevity. The grid panel view is complete.

    I have ensured that each model instance passed to the view has a unique ID. The GridPanel is populating with the correct records. I can edit the records using the row editing plugin without a problem. The problem is that when I click a save button, the page submits a request to the server, but the request has an empty encoded JSON object for the data parameter. Nothing is passed to the server that can be parsed or interpreted to determine the number and content of changed, updated, or deleted record(s).

    Model

        [Model(Name="ProfileStepModel", ClientIdProperty="PhantomId")]
        [JsonWriter(Encode=true, Root="data")]
        public class StationProfileStepModel
        {
            
            [ModelField(IDProperty = true, UseNull=true)]
            [Field(Ignore=true)]
            public int? ID { get; set; }
    
            [ModelField(Ignore=true)]
            public string PhantomId { get; set; }
    
            public string Type { get; set; }
    
            public int Time { get; set; }
    
            public int Channel1PID { get; set; }
    
            public int Channel2PID { get; set; }
    
            public double Channel1SetPoint { get; set; }
    
            public double Channel2SetPoint { get; set; }
    
            public bool Channel1GuaranteedSoak { get; set; }
    
            public bool Channel2GuaranteedSoak { get; set; }
    
            public int LoopFrom { get; set; }
    
            public int LoopTo { get; set; }
    
            public int LoopRepeatCount { get; set; }
    
        }
    Controller
    NOTE: The controller method is called; however, handler indicates there are no updated, changed, or deleted records.
            [HttpPost]
            public ActionResult Steps(int? profileId, StoreDataHandler handler)
            {
                if (handler.IsBatch)
                {
                    ChangeRecords<StationProfileStepModel> steps =
                        handler.BatchObjectData<StationProfileStepModel>();
                    var store = this.GetCmp<Store>("ProfileStepStore");
                }
           }
    View
    NOTE: I am passing a collection of model items in the view's controller function as a parameter to the View function
    @model IEnumerable<StationProfileStepModel>
    
    @(Html.X().GridPanel()
        .ID("ProfileEditorSteps")
        .Title("Profile Steps")
        .Height(500)
        .ColumnWidth(0.80)
        .TopBar(Html.X().Toolbar()
            .Items(
                                    
                Html.X().Button()
                    .Text("Insert Step")
                    .IconAlign(IconAlign.Top)
                    .Icon(Icon.ChartLineAdd),
                                                
                Html.X().Button()
                    .Text("Remove Step")
                    .IconAlign(IconAlign.Top)
                    .Icon(Icon.ChartLineDelete),
                                                
                Html.X().Button()
                    .Text("Clear Profile")
                    .IconAlign(IconAlign.Top)
                    .Icon(Icon.Bin)
                    .OnClientClick("Editor.onClearProfileSteps"),
                                            
                Html.X().Button()
                    .Text("Validate")
                    .IconAlign(IconAlign.Top)
                    .Icon(Icon.Tick)
                                        
            )
        )
        .Plugins(
            Html.X().RowEditing()
                .AutoCancel(false)
                .ClicksToMoveEditor(1)
                                       
        )
        .Store(Html.X().StoreForModel()
            .ID("ProfileStepStore")
        )
        .ColumnModel(
            
            Html.X().RowNumbererColumn()
                .Width(35),    
          
            Html.X().Column().Text("Type")
                .DataIndex("Type")
                .Editor(
                    Html.X().ComboBox()
                        .Items(
                            Html.X().ListItem().Text("Ramp/Soak"),
                            Html.X().ListItem().Text("Loop"),
                            Html.X().ListItem().Text("End")
                        )
                ),
                                            
            Html.X().Column().Text("Time")
                .DataIndex("Time")
                .Renderer("Editor.onRenderStep")
                .Editor(
                    Html.X().NumberField()
                        .AllowBlank(false)
                        .AllowDecimals(true)
                ),
                                            
            Html.X().Column().Text("CH 1 SP")
                .DataIndex("Channel1SetPoint")
                .Renderer("Editor.onRenderStep")
                .Editor(
                    Html.X().NumberField()
                        .AllowBlank(true)
                        .AllowDecimals(true)
                ),
                                            
            Html.X().Column().Text("CH 2 SP")
                .DataIndex("Channel2SetPoint")
                .Editor(
                    Html.X().NumberField()
                        .AllowBlank(true)
                        .AllowDecimals(true)
                ),
                                            
            Html.X().CheckColumn().Text("CH 1 G. Soak")
                .DataIndex("Channel1GuaranteedSoak")
                .Editable(true),
                                            
            Html.X().CheckColumn().Text("CH 2 G. Soak")
                .DataIndex("Channel2GuaranteedSoak")
                .Editable(true),
                                            
            Html.X().Column().Text("CH 1. PID")
                .DataIndex("Channel1PID")
                .Renderer("Editor.onRenderStep")
                .Editor(
                    Html.X().NumberField()
                        .AllowBlank(true)
                        .AllowDecimals(false)
                ),
                                        
            Html.X().Column().Text("CH 2. PID")
                .DataIndex("Channel2PID")
                .Renderer("Editor.onRenderStep")
                .Editor(
                    Html.X().NumberField()
                        .AllowBlank(true)
                        .AllowDecimals(false)
                ),
                                        
            Html.X().Column().Text("Loop From")
                .DataIndex("LoopFrom")
                .Renderer("Editor.onRenderStep")
                .Editor(
                    Html.X().NumberField()
                        .AllowBlank(true)
                        .AllowDecimals(false)
                ),
                                        
            Html.X().Column().Text("Loop To")
                .DataIndex("LoopTo")
                .Renderer("Editor.onRenderStep")
                .Editor(
                    Html.X().NumberField()
                        .AllowBlank(true)
                        .AllowDecimals(false)
                ),
    
            Html.X().Column().Text("Repeat")
                .DataIndex("LoopRepeatCount")
                .Renderer("Editor.onRenderStep")
                .Editor(
                    Html.X().NumberField()
                        .AllowBlank(true)
                        .AllowDecimals(false)
                )
                                            
        )
    
    )
    Save Button
    Html.X().Button()
                        .IconAlign(IconAlign.Top)
                        .Icon(Icon.Disk)
                        .Text("Save")
                        .DirectEvents(e => {
                            e.Click.Url = Url.Action("Steps");
                            e.Click.ExtraParams.Add(new Parameter
                            {
                                Name = "data",
                                Mode = ParameterMode.Raw,
                                Encode = true,
                                Value = "Ext.getCmp('ProfileEditorSteps').store.getChangedData({skipIdForNewRecords: false})"
                            });  
                        })
    Last edited by Daniil; Jan 22, 2013 at 2:21 PM. Reason: [CLOSED]
  2. #2
    I cannot run your sample, you did not provide renderers and bound model data
    Please post view and controller code are not required any changes from our side
    Vladimir Shcheglov
    Sr. Developer
  3. #3

    View and Sample Data

    Here is a more complete example; hopefully this is enough. The renderers were not relevant to the code sample. I forgot to remove them. In my actual code I am returning an ExtPartialViewResult and loading through a ComponentLoader; however, it does not matter if I populate the view with either that method or the method below. I cannot post or attach my actual code due to project confidentiality concerns, but I can provide as many samples as needed to help resolve this issue.

    Controllers/ProfilesController.cs
     public class ProfilesController : Controller
     {
    
            public ActionResult Edit()
            {
                var records = new List<StationProfileStepModel>();
                for (int i = 0; i < 10; i++) 
                    records.Add(new StationProfileStepModel { ID = i, Time = 30 });
    
               return View(records);
            }
    
            [HttpPost]
            public ActionResult Steps(int? profileId, StoreDataHandler handler)
            {
                if (handler.IsBatch)
                {
                    ChangeRecords<StationProfileStepModel> steps =
                        handler.BatchObjectData<StationProfileStepModel>();
                    var store = this.GetCmp<Store>("ProfileStepStore");
                    // NOTE: As explained in the original thread, the handler 
                    // instance exists, along with steps; however, steps contains
                    // no changed, updated, or deleted records.
                }
           }
    
     }
    Views/Profiles/Edit.aspx
    @model IEnumerable<StationProfileStepModel>
    
    @(Html.X().GridPanel()
        .ID("ProfileEditorSteps")
        .Title("Profile Steps")
        .Height(500)
        .ColumnWidth(0.80)
        .TopBar(Html.X().Toolbar()
            .Items(
                                    
                Html.X().Button()
                        .IconAlign(IconAlign.Top)
                        .Icon(Icon.Disk)
                        .Text("Save")
                        .DirectEvents(e => {
                            e.Click.Url = Url.Action("Steps");
                            e.Click.ExtraParams.Add(new Parameter
                            {
                                Name = "data",
                                Mode = ParameterMode.Raw,
                                Encode = true,
                                Value = "Ext.getCmp('ProfileEditorSteps').store.getChangedData({skipIdForNewRecords: false})"
                            });  
                        })
                                        
            )
        )
        .Plugins(
            Html.X().RowEditing()
                .AutoCancel(false)
                .ClicksToMoveEditor(1)
                                       
        )
        .Store(Html.X().StoreForModel()
            .ID("ProfileStepStore")
        )
        .ColumnModel(
            
            Html.X().RowNumbererColumn()
                .Width(35),    
          
            Html.X().Column().Text("Type")
                .DataIndex("Type")
                .Editor(
                    Html.X().ComboBox()
                        .Items(
                            Html.X().ListItem().Text("Ramp/Soak"),
                            Html.X().ListItem().Text("Loop"),
                            Html.X().ListItem().Text("End")
                        )
                ),
                                            
            Html.X().Column().Text("Time")
                .DataIndex("Time")
                .Editor(
                    Html.X().NumberField()
                        .AllowBlank(false)
                        .AllowDecimals(true)
                ),
                                            
            Html.X().Column().Text("CH 1 SP")
                .DataIndex("Channel1SetPoint")
                .Editor(
                    Html.X().NumberField()
                        .AllowBlank(true)
                        .AllowDecimals(true)
                ),
                                            
            Html.X().Column().Text("CH 2 SP")
                .DataIndex("Channel2SetPoint")
                .Editor(
                    Html.X().NumberField()
                        .AllowBlank(true)
                        .AllowDecimals(true)
                ),
                                            
            Html.X().CheckColumn().Text("CH 1 G. Soak")
                .DataIndex("Channel1GuaranteedSoak")
                .Editable(true),
                                            
            Html.X().CheckColumn().Text("CH 2 G. Soak")
                .DataIndex("Channel2GuaranteedSoak")
                .Editable(true),
                                            
            Html.X().Column().Text("CH 1. PID")
                .DataIndex("Channel1PID")
                .Editor(
                    Html.X().NumberField()
                        .AllowBlank(true)
                        .AllowDecimals(false)
                ),
                                        
            Html.X().Column().Text("CH 2. PID")
                .DataIndex("Channel2PID")
                .Editor(
                    Html.X().NumberField()
                        .AllowBlank(true)
                        .AllowDecimals(false)
                ),
                                        
            Html.X().Column().Text("Loop From")
                .DataIndex("LoopFrom")
                .Editor(
                    Html.X().NumberField()
                        .AllowBlank(true)
                        .AllowDecimals(false)
                ),
                                        
            Html.X().Column().Text("Loop To")
                .DataIndex("LoopTo")
                .Editor(
                    Html.X().NumberField()
                        .AllowBlank(true)
                        .AllowDecimals(false)
                ),
    
            Html.X().Column().Text("Repeat")
                .DataIndex("LoopRepeatCount")
                .Editor(
                    Html.X().NumberField()
                        .AllowBlank(true)
                        .AllowDecimals(false)
                )
                                            
        ))
  4. #4
    I tested with latest version (http://svn.ext.net/premium/trunk) and all works fine for me (i see updated records in StoreDataHandler)
    Just one minor issue that 'skipIdForNewRecords' must be replaced by 'skipIdForPhantomRecords'

    What version do you use? Can you update from trunk and retest?
    Vladimir Shcheglov
    Sr. Developer
  5. #5

    Ext.NET Version

    According to Visual Studio the assembly version is 2.1.1.18233. I will retrieve, compile, and link the version in the repository as soon as I get access. For whatever reason my credentials do not work.

    EDIT: I have e-mailed support with a credential reset request as of 4:00 PM EST.
    Last edited by chrish; Jan 21, 2013 at 8:00 PM.
  6. #6
    We have emailed the SVN credentials. Please check.

Similar Threads

  1. Batch Update
    By shaileshsakaria in forum 2.x Help
    Replies: 1
    Last Post: Jan 18, 2013, 4:17 PM
  2. [2.1] GridPanelFor Batch Update
    By millenovanta in forum 2.x Help
    Replies: 20
    Last Post: Dec 26, 2012, 12:27 PM
  3. Replies: 2
    Last Post: Jun 16, 2011, 6:50 AM
  4. [CLOSED] Is there a way to send Store baseParams during Update
    By anup in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 14, 2011, 7:55 AM
  5. How to Update the GridPanel data to the DataSource
    By animalisme in forum 1.x Help
    Replies: 2
    Last Post: Jun 22, 2009, 3:09 AM

Tags for this Thread

Posting Permissions