- popup window for reporting to the visitor of the entire control;
- lack of caching of select data;
- weak extensibility - any functionality must be implemented independently.
- window based design - the resource is intensively edited and it was decided to make the interface windowed;
- since the page could not be reloaded while working on it for hours, the issue of data caching is very acute;
- It is necessary not only to allow the selection of locations, but also to correctly display them, in such, for example, situations like editing, when all selects are already marked and the corresponding lists are already loaded into them.
<head> <script type = "text / javascript" src = "/ lib / ext / adapter / ext / ext-base.js"> </ script> <script type = "text / javascript" src = "/ lib / ext / ext-all.js"> </ script> <script type = "text / javascript" src = "/ lib / ext / ux / locationSelect.js"> </ script> <link href = "/ lib / ext / resources / css / ext-all.css" rel = "stylesheet" type = "text / css" /> </ head>
for check:
use the correct document doctype, often many nontrivialities can be solved once and for all just by starting to work in the correct mode.
important:
A detailed description of the API , configurations and a few examples for each of the controls can be found in the ExtJS API Documentation in the corresponding part of the component tree, packages and classes.
var myForm = new Ext.form.FormPanel ({ items: [{ xtype: 'locationselect', url: '/ someURL', prefix: 'some_location_', title: 'someFieldSetTitle', valueNotFoundText: 'Doesn't matter', validator: function () {/ * some js-code * /} autoHeight: true cache: someCacheVar }] });
- url - address where the control storages will apply for lists of parts of locations (countries, regions and cities), a request will be sent to the same address for a full one-time download of the entire location. For example, Russia | Ryazan region | Ryazan;
- prefix - prefix of variable names in which IDs of parts of the location will be stored. For the case above, when the sub-control is “generated” and sends to the server the variables _some_location_country , _some_location_region , _some_location_city ;
- valueNotFoundText - the value of this field will be assigned to the same-name configuration field of all Ext.form.ComboBox controls;
- validator - the function will be called at the event of selecting any part of the location and will allow, for example, to oblige to specify the location completely;
- cache is a global variable passed by reference, which will be the storage cache of all loadable data. If you create several controls, passing the same cache variable to their constructors, then the controls will use a single cache for all, thereby saving resources. In case the parameter is omitted, the cache for the control will be local, defined inside.
about imperceptible:
Note the underscore character in the names of the variables generated by the prefix. The fact is that the combobox in the ExtJS implementation consists of two input fields - one of which sends the value when the form is submitted; You have to generate two similar names for each combo box.
- When selecting any one part of the location through the combo box, the control “counts” on one array with values ​​for the next combo box in the json-format {rows: [{id: numeric, name: string}, ...]} ;
- When the location is fully loaded, the control needs arrays for the last two combo boxes at a time in json-format {rows: {region: [{id: numeric, name: string}, ...], city: [{id: numeric, name: string} ...]}} .
Source: https://habr.com/ru/post/21931/