What is the best way to save with ExtJS 5 AjaxProxy?

I'm currently in the process of updating an application to ExtJS 5, and I'm encountering difficulties with getting a grid that uses RowEditing to send edited records back to the server via POST.

Ext.define("MyRecordDef", { extend: "Ext.data.Model" });

var MyEditor = Ext.create('Ext.grid.plugin.RowEditing', { clicksToEdit: 1 });

var MyStore = new Ext.data.Store({
        model:      "MyRecordDef",
        autoSync:   true,
        proxy: {
            type:           "ajax",
            url:            "ajaxurl.aspx",
            batchActions:   false,
            extraParams:    { Command: 'Save' },
            reader:         { type: "json", rootProperty: "rows" },
            writer:         { type: "json", encode: true, writeAllFields: true }
        }
    });

var MyGrid = new Ext.grid.GridPanel({
    store:      MyStore,
    plugins:    [ MyEditor ],
    columns:        [
        {
        id:             "fieldtoedit",
        dataIndex:      "fieldtoedit",
        editor:         new Ext.form.NumberField()
        }
    ]
});

Although the row editor pops up, allows me to change values, and click the Update button, unfortunately no action occurs. There is no request sent and no errors appearing in the console.

In an attempt to troubleshoot, I added the following:

MyGrid.on('edit', function (e) {
    alert('You are Editing ' + e.context.record.id);
    MyStore.sync();  // trying to trigger a sync manually
});

Despite receiving the correct record number in the alert, there is still no AJAX request being made. It seems as if ExtJS is completely disregarding the writer configuration.

Since I don't have separate endpoints for each CRUD operation, I am relying on the url instead of utilizing the api config option.

Answer №1

One essential step is to ensure that the rootProperty is defined on the writer when using the option encode: true. Once the fields are added to the definition of MyRecordDef, requests will be sent successfully.

For a demonstration, refer to this sample code: http://example.com/sample (saving functionality may not work, but you can check the console to verify that the request is being sent)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issue with Bootstrap form validation not displaying errors until form submission

I have been working on validating my contact form using Bootstrap 4. Currently, the validation only occurs after submission, but I would like it to highlight errors as soon as incorrect information is entered in a field and the user moves to another field. ...

Tips on how to modify the Firestore field named `likes` by incrementing or decrementing one

I have encountered an issue while trying to update a number field in Cloud Firestore. Despite following the official document and writing the code, it did not produce the desired outcome. It appears that there might be an issue with how I applied async a ...

What is the best way to handle dependencies within AngularJS code?

Hey there, I have a question about managing dependencies. Let's take a look at this example: MyApp.controller("MyController", ["$scope", "$document", "$timeout", "SomeService", function(scope, doc, timeout, service){ /*Some Code here*/ }]); The ...

Tips for embedding a script into an HTML document

I've been experimenting with tinymce npm and following their guide, but I've hit a roadblock. Including this line of code in the <head> of your HTML page is crucial: <script src="/path/to/tinymce.min.js"></script>. So, I place ...

Safari failing to load JavaScript on live website

While JavaScript functions correctly both locally and in production on Chrome, I am facing issues when trying to run it on Safari. Despite having JavaScript enabled on Safari and it working fine locally, it fails to work on the production environment. This ...

Mastering the Art of JSON Conversion for AngularJS

Is there a way to transform the following JSON data structure [{"categories":[{"id":"171","name":"Fashion"},{"id":"219","name":"Blog"}]}] into this format? [{"id":"171","name":"Fashion"},{"id":"219","name":"Blog"}] This change is necessary for proper ...

Using AJAX to delete items from the personalized shopping cart on your WooCommerce website

I am encountering an issue with removing products from the cart. Although my code successfully removes the product in ajax, it fails to refresh the cart. Here is the code snippet I am working with: add_filter('woocommerce_add_to_cart_fragments', ...

Using Angular variables in Laravel blade can add dynamic data and functionality to your web

Just starting out with Angular Js and I'm encountering an issue when trying to use an angular variable in a blade file. The error message I'm getting is: Use of undefined constant count - assumed 'count' (View: C:\xampp\htd ...

Nightwatch failing to locate element within iFrame

I'm currently facing a challenge when trying to access an element within an iframe. Despite successfully switching to the frame, Nightwatch keeps returning "element not found" whenever I attempt to verify its presence or visibility. Below is a snippe ...

Saving user-generated inputs within a React.js component's state, focusing on securely handling passwords

Curious about forms in React.js? I don't have any issues, but I'm wondering if there are potential flaws in my approach. I've set up a basic form with two inputs for email and password: <input type="email" name="email" value= ...

Having trouble retrieving the selected date from the Material-Ui datepicker after the first selection

I am facing an issue with the material-ui dateandtimepicker where I am unable to retrieve the date value on the first select. The value only shows up after the second click, and it's always the previous one. Is there a way to convert the date to a for ...

Is the CRSF protection compromised when a CRSF token is sent alongside an ajax request?

When submitting a form, I ensure security by checking for a CSRF token and validating it. Now, I want to maintain the same level of security when using ajax to submit the form. The ajax request does not actually submit the form itself; it simply sends da ...

An error is not being thrown within an asynchronous function

I am facing an issue with an async function that inserts data into a database using the mariadb package. If there is a duplicate unique key error, it throws an error as expected. However, when I attempt to rethrow the error to catch it in the Promise, it a ...

Run JavaScript code whenever the table is modified

I have a dynamic table that loads data asynchronously, and I am looking for a way to trigger a function every time the content of the table changes - whether it's new data being added or modifications to existing data. Is there a method to achieve th ...

Error copying cell width attribute when using border collapse

Currently, I am attempting to duplicate a table header by copying the tr HTML and then replicating the th widths. Unfortunately, this method is unsuccessful as the widths are displayed as (width minus W) pixels when border: 'Wpx' and border-colla ...

The dropdown feature on my theme seems to be malfunctioning on Wordpress

I'm having trouble figuring out what I'm doing wrong. The dropdown navigation works fine with the default Wordpress twentyeleven theme, but when I switch to my custom theme, the dropdown stops appearing. Here is the code I'm using: <div ...

Is there a way to verify if a JSP successfully navigated to the controller in a Spring MVC application? Furthermore, how can one showcase a list from the

In my setup, I have a Spring MVC program running on Tomcat which features a datatable. When a user interacts with a button within the table, specific row values associated with that button are then transmitted to the controller. To provide a visual repres ...

Issue with formatting data correctly in JSON file while using Express.js

I am facing an issue with loading data from a JSON file into an array in the correct format: var jobs = [ { ID: 'grt34hggdggf', Employer: 'A1', Title: 'tobi1', Location: 'Los Angeles, CA', Department: 'depart ...

When utilizing JavaScript syntax and performing API testing with Postman

Hello, I need some assistance from experts in connecting to Postman using the JavaScript code provided below. When running nodemon, the connection appears to be normal with no errors. Also, the GET request sent to Postman works fine. However, I am encounte ...

Matching a string with a variable in JavaScript: A simple guide

Can you assist me? I am trying to have activeLayers = [bus,stops,slot1] instead of activeLayers = ["bus","stops","slot1"]. How can I achieve this? Essentially, I want to convert the string into the object it references. Unfortunately, my current approach ...