Extjs4 Combobox interaction always causes a loading error. extjs4combobox

Source: Internet
Author: User

Extjs4 Combobox interaction always causes a loading error. extjs4combobox

When combobox is selected repeatedly, the lower-level Combobox will have a loading error, even though the Store data has been loaded.

You will know how to deal with the Code: (pay attention to the key statements in the red part)


},{
Xtype: 'combobox ',
LabelStyle: 'color: blue ;',
LabelWidth: 70, // label width
Width: 200, // field width
MsgTarget: 'day ',
AllowBlank: false, // whether null values are allowed
LabelStyle: 'color: red ;',
Value :'',
EmptyText: 'select a superior department .... ',
QueryMode: 'local ',
DisplayField: 'deptname ',
ValueField: 'deptname ',
Store: myUpDeptStore,
Editable: false,
TriggerAction: 'all ',
FieldLabel: "superior department ",
Listeners :{
'Select': function (combo, record, number) {// This event returns the record value of the selected item in the store. The index parameter is the Sn.
Var _ value = combo. getValue ();
Ext. getCmp ('addptcombo '). clearValue ();
Ext. getCmp ('addptcombo '). store. load ({params :{
UpDept: _ value // record [0]. data. DeptName
}
});
}
},
Name: "UpDept"
},{
Xtype: 'combobox ',
Id: 'addptcombo ',
DefaultListConfig: {// cancel the loading Mask
LoadMask: false
},
LabelStyle: 'color: blue ;',
LabelWidth: 70, // label width
Width: 200, // field width
MsgTarget: 'day ',
AllowBlank: false, // whether null values are allowed
LabelStyle: 'color: red ;',
Value :'',
EmptyText: 'select a department/team .... ',
QueryMode: 'local ',
DisplayField: 'deptname ',
ValueField: 'deptname ',
Store: myDeptStore,
Editable: false,
FieldLabel: "department ",
Name: "Dept"
}]


Note: This error should be caused by the Extjs Bug. The data has been loaded but the Mask layer has not been canceled, so we can only remove it manually.


Extjs40 ComboBox combo box cascade problem after selecting the province in the first ComboBox, the second ComboBox will show the city in the province

The Code style is very different. I encountered this problem before, because of the successive problems of loading combobox and loading data.

The solution is to load combox and data first. The Code is as follows:
Ext. onReady (function (){
// Province
New Ext. form. ComboBox ({
Id: 'sf ',
// The province data is automatically loaded.
Store: Ext. create ('ext. data. store', {fields: ['name']}),
DisplayField: 'name ',
ValueField: 'name ',
Listeners :{
'Blur': askCity
}
});
});

Function askCity (){
Ext. Ajax. request ({
Url: 'xxx. jsp ',
Params :{
Sf: Ext. get ('sf '). getValue ()
},
Success: function (response ){
// Removeall is not required here, because the returned data will only be cities in the province
Var respText = Ext. decode (response. responseText );
Ext. get ('cs '). store. loadData (respText );
},
Failure: function (response ){
Ext. Msg. alert ('unexpected ', 'unexpected Data Request occurred, Please refresh the page ');
}
});
}

// The city's combo does not load data for the first time, or fill in a blank text: 'select a province ',

In ExtJs, the two comboboxes are selected after Association, and the first and second are selected to bind the corresponding data. How can this problem be solved?

Ext. onReady (function (){
Ext. QuickTips. init ();
Var provinces = [[1, 'beijing'], [2, 'shanghai'];
Var cities = new Array ();
Cities [1] = [[11, 'haidian '], [22, 'dongcheng'];
Cities [2] = [[33, 'whampoa '], [44, 'pudong'], [55, 'jingan '];
Var comboProvinces = new Ext. form. ComboBox ({
Store: new Ext. data. SimpleStore ({
Fields: ["provinceId", "provinceName"],
Data: provinces
}),
Listeners :{
Select: function (combo, record, index ){
ComboCities. clearValue ();
ComboCities. store
. LoadData (cities [record. data. provinceId]);
}
},
ValueField: "provinceId ",
DisplayField: "provinceName ",
Mode: 'local ',
ForceSelection: true,
BlankText: 'select a province ',
EmptyText: 'select a province ',
HiddenName: 'propineid ',
Editable: false,
TriggerAction: 'all ',
AllowBlank: true,
FieldLabel: 'select a province ',
Name: 'propineid ',
Width: 80
});
Var comboCities = new Ext. form. ComboBox ({
Store: new Ext. data. SimpleStore ({
Fields: ["cityId", 'cityname'],
Data: []
}),
ValueField: "cityId ",
DisplayField: "cityName ",
Mode: 'local ',
ForceSelection: true,
BlankText: 'select region ',
EmptyText: 'select region ',
HiddenName: 'cityid ',
Editable: false,
TriggerAction: all

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.