There is another solution to extjs grid replication.

Source: Internet
Author: User

There is another solution to extjs grid replication.

Although extjs is often used in previous projects, it may not be noticed, or it may not be necessary to use this function at all.

When talking to the customer a few days ago, the customer said that he wanted to copy the data in the gird table. At that time, he didn't think much about it. I felt that extjs should support this function, you should configure the following parameters. but after I came back, I checked the extjs api and found that there was no such setting at all. I think back to the previous project, it seems that I have not done this function. so I quickly went to the Internet and found some solutions, but I felt it was troublesome to implement them and didn't try it.

When I think about this problem again today, suddenly an idea is flashing in my mind. I should be able to use the cell editing function of gird to achieve the replication effect. so hurry up and test the results. The Code is as follows:

Ext.create('Ext.data.Store', {    storeId:'simpsonsStore',    fields:['name', 'email', 'phone'],    data:{'items':[        { 'name': 'Lisa',  "email":"lisa@simpsons.com",  "phone":"555-111-1224"  },        { 'name': 'Bart',  "email":"bart@simpsons.com",  "phone":"555-222-1234" },        { 'name': 'Homer', "email":"home@simpsons.com",  "phone":"555-222-1244"  },        { 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254"  }    ]},    proxy: {        type: 'memory',        reader: {            type: 'json',            root: 'items'        }    }});Ext.create('Ext.grid.Panel', {    title: 'Simpsons',    store: Ext.data.StoreManager.lookup('simpsonsStore'),    plugins: [        Ext.create('Ext.grid.plugin.CellEditing', {            pluginId:'rowEditing',            clicksToEdit: 1        })    ],    columns: [        { text: 'Name',  dataIndex: 'name' ,         editor:{             xtype: 'displayfield'         }        },        { text: 'Email', dataIndex: 'email', flex: 1 },        { text: 'Phone', dataIndex: 'phone' }    ],    height: 200,    width: 400,    renderTo: Ext.getBody()});

The effect is as follows:


I think the effect is good,

To sum up, it is obvious that the implementation is simple and convenient, and supports extjs of various versions. It is determined that row replication is not supported, and an editor must be written for each column.

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.