mass editing - undesired demands or data bombardment

Lately, I've been extremely frustrated with an issue I've encountered over the past 4 days. When attempting to update multiple items within my store simultaneously, I'm experiencing a strange payload behavior. To elaborate on what I mean by "weird": the first request contains data for the first item, the second request includes data for the first and second items, and this pattern continues as more items are updated.

Disabling batchActions results in 55 requests for 10 items in my store. The problem escalates when editing 30 items, leading to a staggering 465 requests!

Below is the code snippet:

<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link href="extjs/resources/css/ext-all.css" rel="stylesheet" type="text/css" />
    <script src="extjs/ext-all-debug-w-comments.js" type="text/javascript"></script>
    <title>Test</title>
    <script type="text/javascript">
        //MODEL
        Ext.define('Test.model.Shift', {
            extend: 'Ext.data.Model',
            idProperty: 'id',
            fields: [{
                name: 'id',
                type: 'int'
            }, {
                name: 'StartDate',
                type: 'date',
                dateFormat: 'Y-m-d'
            }, {
                name: 'EndDate',
                type: 'date',
                dateFormat: 'Y-m-d'
            }, {
                name: 'Cls',
                type: 'string'
            }, {
                name: 'Draggable',
                type: 'bool',
                defaultValue: true
            }, {
                name: 'Resizable',
                type: 'bool',
                defaultValue: true
            }]
        });


         //STORE
        Ext.define('Test.store.Shifts', {
            extend: 'Ext.data.Store',
            model: 'Test.model.Shift',
            autoLoad: true,
            autoSync: true,//I need this!!!
            proxy: {
                type: 'rest',
                //batchActions: true,
                pageParam: false,
                startParam: false,
                limitParam: false,
                noCache: false,
                url: 'json.php',
                reader: {
                    type: 'json',
                    root: 'data'
                },
                writer: {
                    type: 'json'
                }
            },
            listeners: {
                update: function (store, record, operation, eOpts) {
                    switch (operation) {
                    case Ext.data.Model.EDIT:
                        console.log('INFO', 'Updating record...');
                        break;
                    case Ext.data.Model.COMMIT:
                        console.log('INFO', 'Record was updated!');
                        break;
                    case Ext.data.Model.REJECT:
                        console.log('ERR', 'Something went horribly wrong :( Data was rejected!');
                        break;
                    }
                },
                beforesync: function (options, eOpts) {
                    console.log(options);
                }
            }
        });

...

For any advice or suggestions on how to tackle this issue would be greatly appreciated. You can access my test page here:

EDIT:
To test another PUT response, I made modifications to the original example provided with ExtJS 4.2.1 - restfull example. I added the following code to the toolbar:

{
    itemId: 'updateAll',
    text: 'Update All',
    handler: function(){
        Ext.each(grid.store.getRange(), function (rec, index) {
            rec.set('last', 'Test');
        }, this);
    }
}

This functionality allows me to update all records at once. However, even for just 6 records, I observe 21 requests being sent. You can view this additional test here:

EDIT 2

I have now implemented a version that works better for me:

{
    itemId: 'updateAll',
    text: 'Update All',
    handler: function(){
        grid.store.suspendAutoSync();
        Ext.each(grid.store.getRange(), function (rec, index) {
            rec.set('last', 'Test'+ Math.floor(Math.random() * 100)  );
        }, this);
        grid.store.resumeAutoSync();
        grid.store.sync();
    }
}

This process involves halting autosync, making local changes, then resuming autosync before syncing all the changes.

Answer №1

Here is an explanation of how ExtJS handles data updates:

  1. The request is sent with the json data.
  2. The response is then parsed.
    • If the record was updated successfully, the update operation is removed from the queue.
    • If the record failed to update, the update operation remains in the queue and will be resent in the next attempt.

If you are experiencing repeated requests being sent, it may be due to receiving incorrect responses from the server. For instance, when updating Cls from cls to cls2, the data sent to the server should look like this:

{"id":7,"StartDate":"2013-01-06","EndDate":"2013-01-08","Cls":"cls2","Draggable":true,"Resizable":true}

The expected response from the server should be:

{"success":true,"data":[{"id":7,"StartDate":"2013-01-06","EndDate":"2013-01-08","Cls":"cls2","Draggable":true,"Resizable":true}]}

If the server returns all lines without the expected update, specifically showing "Cls":"cls" instead of

"Cls":"cls2"</code, ExtJS interprets this as a failed update despite receiving <code>success: true
. This results in ExtJS resending the update operation with each store.sync().

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

Using jQuery UI datepicker - how to set a parameter based on a specific condition

New to the world of JavaScript, I am trying my hand at implementing the jQuery UI datepicker widget. My goal is to add an additional line to the widget parameters if the variable selectedDate has a value. However, my current approach seems to be ineffecti ...

"Unlocking the secret to fetching the id of the clicked element within a Highchart context menu

Is it possible to retrieve the id of a clicked button on the highchart context menu? Alternatively, is there a way to execute the click function twice? const contextButtonArray = []; contextButtonArray.push({ { text: 'TEST BUTTON&ap ...

Revise my perspective on a modification in the backbone model

I am new to using Backbone and I am currently practicing by creating a blog using a JSON file that contains the necessary data. Everything seems to be working, although I know it might not be the best practice most of the time. However, there is one specif ...

Troubleshooting broken links on a multi-page website built with node.js and ejs

I am encountering some difficulties with my multi-page website created in node.js/ejs. I suspect that the issue lies within the routing mechanism, although I have double-checked my routes and they seem to be configured correctly. The problem arises when I ...

Enlargement animation when hovering over a "next-link" button featuring an SVG file of a social media platform

The following code snippet demonstrates how to import an Instagram icon and create a footer component: import InstagramIcon from './assets/IG.svg'; export const Footer = ({ footer }: FooterInterface) => { return ( ..... <Link href={`${fo ...

Updating Mapped Components with Selected State

One of the components in my project is a mapped component that dynamically displays API data. Each card displayed by this component receives unique props, resulting in cards that look different from one another. An example can be seen below. View Example ...

Finding the precise source domain address using javascript

I'm having trouble retrieving the original domain address. I've attempted using document.location and $location, but haven't found a solution. Instead of the actual domain address, it returns the IP address. After trying window.location.anc ...

Allow clicking through the iframe, while still able to interact with its contents

I am facing a challenge of making an iframe click-through, while ensuring that the body of the iframe remains clickable. I have attempted to achieve this using the following code: iframe.style.width = '100%' iframe.style.height = '100%&apos ...

Phonegap - Retaining text data in a checklist app beyond app shutdown

This is my first time developing an app with Phonegap. I am looking to create a checklist feature where users can input items into an input field. However, I am struggling with figuring out how to save these items so that they remain in the checklist even ...

Struggling to understand why my React Component is failing to render properly

Could there be an issue with how I imported react or am I simply overlooking something small? Any feedback would be greatly appreciated. As a beginner in programming, I may be missing a simple solution that I'm not experienced enough to identify. Than ...

Stopping animation in jQuery function before it starts

After each update, a function is executed: window.ticker.client.updateData = function (data) { try { if (viewModelOrder.selectedInstrument == data.symbol) { viewModelOrder.updatePrice(data.ask.to ...

I'm looking to learn how to efficiently write file chunks from a video upload in Node Js. How can I

My current project involves attempting to stream webcam or audio data to Node.js and save it on disk. The aim is to send the chunks of data to the server as soon as they are available. I have successfully captured the stream using getUserMedia, set up me ...

Determine the quantity of items currently in an active state

I created a function that toggles the active state of list items when clicked: React toggleActive: function(item){ item.active = !item.active; }, JSX <li key={property.id} onClick={() => this.toggleActive(property)}> Is there a way to count ...

Combining Ng-model with iOS credit card scanning functionality offers a seamless and

Dealing with Ng-model and iOS credit card scanning In my credit card form, each field is structured like this: <input type=“text” ng-model = “cc.number”, ng-class = validClass('cc.number’)> The function validClass returns either val ...

Prevent code from freezing due to JavaScript errors within jQuery blockUI

Trying to make sense of things... We're utilizing the jQuery block UI plugin to block the UI. $(document).ajaxStart(function() { $.blockUI({ message: '<h4><i class="fa fa-circle-o-notch fa-spin fa-fw"></i> loading...< ...

What is the code to convert data to base64 in Javascript when it is not a string?

I am in the process of transferring functionality from an Objective-C iPhone application to a JavaScript iPhone application (using Appcelerator Titanium). In my Objective-C code, I have an NSData object that represents a specific token: //NSData object sh ...

React - Array of objects not being reversed when imported

Hey there! I'm currently struggling with reversing an array of objects that I'm importing from a separate js file. The strange thing is, it only seems to work when I directly input the array into the component where I want to display the data. An ...

How can I prevent the state from being overridden in the reducer function when updating the State Context API?

I'm currently facing an issue with my reducer case where it ends up overwriting the passed id instead of simply adding to the existing array of ids. Can you enlighten me on the fundamental concept behind state copying and clarify when to utilize the s ...

The response to ajax requests does not appear in Chrome Dev Tools

I'm experiencing an issue with my nodejs application where I encounter a peculiar situation when making ajax requests using jQuery. When I make a redirection in the callback function of the AJAX request, the response in the developer tools appears emp ...

Winston inquired about the process of log rotation

Is there a way to enable log rotation in Winston for managing logging in node.js? Specifically, is there a method to generate a new log file for each day the application is active? var logger = new (winston.Logger)({ transports: [ n ...