Ext js lock grid reconfig demo

Source: Internet
Author: User

Ext js lock grid reconfig demo

When the grid calls the reconfigure function, sometimes the lock Column cannot be correctly displayed. Add the attribute enableLocking: true to the Extjs 4.2.2.1144 grid to display it normally.

In addition:

ColumnLines: false, // whether to display the column border

RowLines: false, // whether to display the row border


Reconfiggrid. js

Ext. define ('kitchensink. model. grid. office ', {extend: 'ext. data. model ', fields: ['city', 'totalemployees', 'manager']}); Ext. define ('kitchensink. model. grid. employee ', {extend: 'ext. data. model ', fields: [{name: 'ployeeno'}, {name: 'rating', type: 'int'}, {name: 'salary', type: 'float'}, {name: 'forename'}, {name: 'surname'}, {name: 'name', convert: function (v, rec) {return rec. editing? V: rec. get ('forename') + ''+ rec. get ('surname') ;}},{ name: 'email '}, {name: 'department'}, {name: 'dob', type: 'date ', dateFormat: 'ymmd'}, {name: 'jobdate', type: 'date', dateFormat: 'ymmd'}, {name: 'noticeperiod '}, {name: 'sickdays ', type: 'int'}, {name: 'holidaydays', type: 'int'}, {name: 'holidayallowance ', type: 'int '}, {name: 'Avatar '}], idField: 'ployeeno', afterEdit: Function (modifiedFieldNames) {// "name" is a calculated field, so update it on edit of "forename" or "surname ". if (Ext. array. contains (modifiedFieldNames, 'forename') | Ext. array. contains (modifiedFieldNames, 'surname') {this. data. name = this. data. forename + ''+ this. data. surname; modifiedFieldNames. push ('name');} // Likewise, update two name fields if whole name gets updated else if (Ext. Array. contains (modifiedFieldNames, 'name') {var names = this. convertName (this. data. name); this. data. forename = names [0]; this. data. surname = names [1]; modifiedFieldNames. push ('forename', 'surname');} return this. callParent (arguments) ;}, convertName: function (name) {var names =/([^ \ s +] + )(?: \ S + (.*))? /. Exec (name); return names? [Names [1], names [2] | '']: ['', ''] ;}}); Ext. define ('kitchensink. view. grid. reconfigure ', {extend: 'ext. container. container ', requires: ['ext. grid. * ', 'ext. layout. container. hbox', 'ext. layout. container. vbox', 'kitchensink. model. grid. office ', 'kitchensink. model. grid. employee '], xtype: 'reconfigure-grie', layout: {type: 'vbox', align: 'Stretch'}, width: 500, height: 330, lastNames: ['Jones ', 'Smith', 'Lee ', 'wilson', 'black', 'williams ', 'Lewis', 'johnson ', 'foot ', 'Little ', 'vee', 'train', 'hot ', 'mutt'], firstNames: ['fred', 'julil', 'bill ', 'ted ', 'jack', 'john', 'mark', 'Mike ', 'chris', 'bob', 'travis ', 'Kelly', 'sara'], cities: ['New York ', 'Los Angeles', 'Chicago', 'houston ', 'philadelphia', 'phoenix ', 'san Antonio', 'san Diego ', 'Dallas ', 'san jose'], attributes: ['development', 'qa', 'marketing', 'accounting', 'sales'], initComponent: function () {Ext. apply (this, {items: [{xtype: 'Container', layout: 'hbox', defaultType: 'click', items: [{itemId: 'showoffices ', text: 'Show offices', scope: this, handler: this. onShowOfficesClick}, {itemId: 'showemployees', margin: '0 0 0 10', text: 'Show ployees', scope: this, handler: this. onShowEmployeesClick}]}, {margin: '10 0 0 0', xtype: 'grie', flex: 1, columns: [], enableLocking: true, // columnLines: false, rowLines: false, viewConfig: {trackOver: false, stripeRows: false, emptyText: 'click a button to show a dataset ', deferEmptyText: false}]}); this. callParent () ;}, onShowOfficesClick: function () {// reconfigure grid var grid = this. down ('grid'); Ext. suspendLayouts (); grid. setTitle ('ployees'); grid. reconfigure (this. createOfficeStore (), [{xtype: 'rownumberer', width: 40, align: 'center', locked: true, resizable: false}, {flex: 1, text: 'city', dataIndex: 'city'}, {text: 'total ployees', dataIndex: 'totalemployees', width: 140}, {text: 'manager', dataIndex: 'manager', width: 120}]); this. down ('# showEmployees '). enable (); this. down ('# showOffices '). disable (); Ext. resumeLayouts (true) ;}, onShowEmployeesClick: function () {// reconfigure grid var grid = this. down ('grid'); Ext. suspendLayouts (); grid. setTitle ('ployees'); grid. reconfigure (this. createEmployeeStore (), [{xtype: 'rownumberer', width: 40, align: 'center', locked: true, resizable: false}, {text: 'First name ', dataIndex: 'forename'}, {text: 'Last name', dataIndex: 'surname'}, {width: 130, text: 'employee No. ', dataIndex: 'ployeeno'}, {flex: 1, text: 'department', dataIndex: 'department '}]); this. down ('# showOffices '). enable (); this. down ('# showEmployees '). disable (); Ext. resumeLayouts (true) ;}, createEmployeeStore: function () {var data = [], I = 0, usedNames ={}, name; for (; I <20; ++ I) {name = this. getUniqueName (usedNames); data. push ({forename: name [0], surname: name [1], employeeNo: this. getEmployeeNo (), department: this. getDepartment ()});} return new Ext. data. store ({model: KitchenSink. model. grid. employee, data: data}) ;}, createOfficeStore: function () {var data = [], I = 0, usedNames ={}, usedCities ={}; (; I <7; ++ I) {data. push ({city: this. getUniqueCity (usedCities), manager: this. getUniqueName (usedNames ). join (''), totalEmployees: Ext. number. randomInt (10, 25)});} return new Ext. data. store ({model: KitchenSink. model. grid. office, data: data}) ;}, // Fake data generation functions generateName: function () {var lasts = this. lastNames, firsts = this. firstNames, lastLen = lasts. length, firstLen = firsts. length, getRandomInt = Ext. number. randomInt, first = firsts [getRandomInt (0, firstLen-1)], last = lasts [getRandomInt (0, lastLen-1)]; return [first, last];}, getUniqueName: function (used) {var name = this. generateName (), key = name [0] + name [1]; if (used [key]) {return this. getUniqueName (used);} used [key] = true; return name;}, getCity: function () {var cities = this. cities, len = cities. length; return cities [Ext. number. randomInt (0, len-1)];}, getUniqueCity: function (used) {var city = this. getCity (); if (used [city]) {return this. getUniqueCity (used);} used [city] = true; return city;}, getEmployeeNo: function () {var out = '', I = 0; (; I <6; ++ I) {out + = Ext. number. randomInt (0, 7);} return out;}, getDepartment: function () {var departments = this. parameters, len = parameters. length; return parameters [Ext. number. randomInt (0, len-1)] ;}}); Ext. onReady (function () {Ext. quickTips. init (); Ext. BLANK_IMAGE_URL = '/images/s.gif'; var mainGrid = Ext. create ('kitchensink. view. grid. reconfigure '); mainGrid. render (Ext. getBody ());});

Reconfiggrid.html

re        
     
             
                    <script type="text/javascript" src="./Ext/ext-all-debug.js"></script>    <script type="text/javascript" src="./Ext/ext-theme-neptune.js"></script>        <script type="text/javascript" src="./reconfiggrid.js"></script>

Display


Refer:

Http://www.sencha.com/forum/showthread.php? 146920-Grid-bug-when-using-reconfigure ()-and-locked-column

Http://www.sencha.com/forum/showthread.php? 214173

Http://www.sencha.com/forum/showthread.php? 248686





Zookeeper

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.