Pull out the bugs you have not encountered in ExtJS3.4 (1)

Source: Internet
Author: User
From today on, all I have to do is to constantly update and constantly disclose and fix the ExtJS34 BUG. Note that the version is 34 rather than 40, because the 40 changes and changes are relatively large, so do not block the number. Hey, I am not writing much, but these bugs are bothering me.

From today on, all I have to do is constantly update and constantly disclose and fix ExtJS 3.4 bugs. Note that the version is 3.4 rather than 4.0. Because the version 4.0 changes and changes are large, do not use the check mark.

Hey, I don't know how to write things, but these bugs have plagued me for a long time, so it hurts a lot.

The Bug fix method mentioned in this Article does not modify the original code. You only need to introduce an external file.

Whether you are using this framework or have used this framework, note that your ExtJS version is 3.4.

In addition, I do not guarantee updates every day, so writing or writing articles is dependent on the bug I encountered at work. All right.

You need to pay attention to the Javascript basics when viewing this article.

BUG source Ext. data. DataStore

BUG description, causing Automatic Data Storage Using JsonWriter.

Trigger BUG Configuration:

Ext. data. JsonWriter-> listfu: true

Ext. data. DataStore-> autoSave: true

Ext. data. DataStore-> JsonWriter set as listfu

This BUG can be triggered when the preceding conditions are met.

Trigger environment:

When you delete two or more data using the remove Method of Ext. data. Store.

Red is the source code that causes the BUG:

Ext. data. Store

remove : function(record){        if(Ext.isArray(record)){            Ext.each(record, function(r){                this.remove(r);            }, this);            return;        }        var index = this.data.indexOf(record);        if(index > -1){            record.join(null);            this.data.removeAt(index);        }        if(this.pruneModifiedRecords){            this.modified.remove(record);        }        if(this.snapshot){            this.snapshot.remove(record);        }        if(index > -1){            this.fireEvent('remove', this, record, index);        }    },

Listing 1

Related code:

if (this.writer) {            this.on({                scope: this,                add: this.createRecords,                remove: this.destroyRecord,                update: this.updateRecord,                clear: this.onClear            });        }
List 2

destroyRecord : function(store, record, index) {        if (this.modified.indexOf(record) != -1) {              this.modified.remove(record);        }        if (!record.phantom) {            this.removed.push(record);                                                record.lastIndex = index;            if (this.autoSave === true) {                this.save();            }        }    },

Listing 3

Okay, let me briefly describe this BUG. Because Store adds the event remove itself, a remove event will be triggered when a record (Ext. data. Record) is removed.

For example, to clear the red code of a single type, this event is called. This method is passed to the destroyRecord method. Pay attention to this. autoSave snippet in the code.

Because listful and autoSave are enabled, an ajax call is used.

However, because we delete multiple data records, this call will be executed multiple times.

If you delete one entry, it will be executed once. If you delete two entries, It will be executed twice. If you delete three entries, It will be executed three times.

Here is the external code to fix this BUG, please introduce this code after ext-all.js or ext-all-debug.js, you can create a new file for reference.

Ext. apply (Ext. data. store. prototype, {_ bustm_remove: function (record) {var index = this. data. indexOf (record); if (index>-1) {record. join (null); this. data. removeAt (index);} if (this. pruneModifiedRecords) {this. modified. remove (record);} if (this. snapshot) {this. snapshot. remove (record);} if (index>-1) {this. fireEvent ('delete', this, record, index) ;}}, // overwrite existing methods. Remove: function (record) {if (Ext. isArray (record) {Ext. each (record, function (r) {this. _ bug0_remove (r) ;}, this) ;} else {this. _ bustm_remove (record);} if (this. autoSave = true) {this. save () ;}}, // overwrite existing methods. Allow the method to support multiple records. DestroyRecord: function (store, record, index) {if (this. modified. indexOf (record )! =-1) {this. modified. remove (record);} if (! Record. phantom) {this. removed. push (record); record. lastIndex = index; // Delete this method and modify the call logic. // if (this. autoSave = true) {// this. save ();//}}},})

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.