PDA

View Full Version : Unable to load my combo for first time(after combo is set by form load method)



vinodpadmanaban@gmail.com
29 Sep 2011, 5:22 AM
Hi ,
I load my form from grid to edit the grid data by using
form.loadRecord(record);
after that if i try to trigger the combo its expands little and collapse automatically for first time ,second time it loads normally
pls download this link (http://www.4shared.com/file/ySBR_McK/form.html)to know my issue (Pls click the load button first and click the combo trigger ..first time it will come and hide and second time loads normally)

i thing iam missing some property .

thanks

jay@moduscreate.com
29 Sep 2011, 11:15 AM
I'm not going to download your code. :(

Is the store setup to use an ajax proxy? is the mode set to local if you are loading data locally?

vinodpadmanaban@gmail.com
30 Sep 2011, 11:19 AM
hi jgarcia (http://www.sencha.com/forum/member.php?172-jgarcia-tdg-i.com),

yes i set ajax proxy and i have not set the

queryMode property, so it takes default as 'remote'.below is my code..

i added the combo(Window->form->combo)


{
xtype : 'combobox',
editable : false,
id:'userCategoryCmbo',
queryMode: 'remote',
displayField: 'userCategory',
valueField: 'userCategory',
store :new Ext.data.Store({
autoLoad: true,
fields: [ 'userCategory' ],
proxy: {
type: 'ajax',
extraParams: {typeName : 'usrType'},
url : 'UsrCatgry.htm',
reader: {
type: 'json',
root : 'res'
}
}

}),
name : 'userCategory',
fieldLabel: 'Category'
}

this code will hit the database,
but i also tried using json file,i think it will be more easier for you guys to understand my issue
because of this i uploaded as link.

thanks

vinodpadmanaban@gmail.com
3 Oct 2011, 10:28 AM
I'm not going to download your code. :(

Is the store setup to use an ajax proxy? is the mode set to local if you are loading data locally?

hi jgarcia (http://www.sencha.com/forum/member.php?172-jgarcia-tdg-i.com),

yes i set ajax proxy and queryMode property= 'remote'.

below is my code..

i added the combo(Window->form->combo)



{
xtype : 'combobox',
editable : false,
id:'userCategoryCmbo',
queryMode: 'remote',
displayField: 'userCategory',
valueField: 'userCategory',
store :new Ext.data.Store({
autoLoad: true,
fields: [ 'userCategory' ],
proxy: {
type: 'ajax',
extraParams: {typeName : 'usrType'},
url : 'UsrCatgry.htm',
reader: {
type: 'json',
root : 'res'
}
}

}),
name : 'userCategory',
fieldLabel: 'Category'
}



this code will hit the database,
but i also tried using json file,i think it will be more easier for you guys to understand my issue
because of this i uploaded as link.:-/

thanks

skirtle
3 Oct 2011, 5:28 PM
As already suggested, your queryMode is set incorrectly. This setting causes much confusion because its values are unhelpfully named. It has very little to do with where your data actually comes from.

local: The combobox does not need to do anything to request the data. It should just observe the store and display its contents when they are available.

remote: The combobox should initiate the store loading when it first needs the data. The store will not load the data until told to do so by the combobox.

In your case you have autoLoad: true on your store, so you should put queryMode: 'local' on your combobox.

All of that said, I'm not convinced this is necessarily the cause of your problems but I don't see any other obvious mistakes in your config so it's worth a try.

jpcook01
4 Oct 2011, 12:59 AM
I have the same problem also, adding queryMode: local doesn't do anything. I want my combo box to automatically select the first item from the store.



Ext.define('NavBuilder.SitemapComboStore', {
extend: 'Ext.data.Store',

model: 'NavBuilder.SitemapItem',
proxy: {
type: 'ajax',
url: 'sitemap/list'
},
autoLoad: true,
queryMode: 'local',
listeners: {
load: function(store, records, successful, operation, eOpts ){
this.sitemapcombo.setValue(store.getAt(0).get('uri'));
}
}
});


and this is the actual combo box


initComponent: function(){
Ext.apply(this, {
forceSelection: true,
editable: false,
fieldLabel: 'Sitemap',
labelWidth: 50,
mode: 'local',
width: 270,
name: 'selectsitemapcombo',
itemId: 'selectsitemapcombo',
displayField: 'uri',
valueField: 'uri',
selectOnFocus: true,
store: Ext.create('NavBuilder.SitemapComboStore', { sitemapcombo: this }),
listeners: {
change: this.onChangeHandler
}
});
this.callParent();
},

onChangeHandler: function(combo) {
var tree = combo.up('treepanel');
var store = tree.getStore();

store.setProxy({
type: 'ajax',
url: 'sitemap/' + combo.getValue()
});

tree.setRootNode({
text: combo.getValue(),
expanded: true
});

}

jpcook01
4 Oct 2011, 1:49 AM
I fixed it by adding the following to my combo box


lastQuery: '',

vinodpadmanaban@gmail.com
5 Oct 2011, 9:40 AM
Hi skirtle and jgarcia

Yes i understand the concept. Thanks lot for explanation.

but how to do for the combo(querymode 'remote') like pagination combo.

i did like, first i pass the comboset value through 'query' in window show event and set the combobox,
after in combo first trigger i need to get all the data from the first(i.e firstpage(no filter query))

combo trigger not hitting the database.

by the below code i need to remove the data manually(clear the combo) and enter the filter value like 'a' to trigger to get the related data.but i need it in trigger itself

how to implement this ,any property to reset the filter query in every combo trigger.

this is the pagination combo code

{
xtype : 'combobox',
editable : true,
queryMode: 'remote',
displayField: 'typeValue',
valueField: 'typeValue',
selectOnFocus: true,
triggerAction:'all',
name : 'majorOperator',
lastQuery:'',
store : new Ext.data.Store({
pageSize:10,
idProperty : 'pid',
autoLoad: false,
fields : [ 'pid', 'rid', 'typeValue' ],
proxy: {
type: 'ajax',
extraParams: {versionIndex :'xyz',query:'',start:0, limit:10},
url : 'airList.htm',
reader: {
type: 'json',
root : 'res',
totalProperty: 'totalCount'
}
}
}),
fieldLabel: 'Operator',
pageSize:10,
minChars:1 ,
listeners: {
//beforequery: function(qe){//load from store every time
// qe.combo.lastQuery=null;
// }
}

}






i tried beforequery event .


beforequery: function(qe){//load from store every time
qe.combo.lastQuery=null;
}
its not getting in first trigger but getting in the second trigger and also
Problem continues after every selection (i.e after every combo select ,first trigger not loads the data )

vinodpadmanaban@gmail.com
5 Oct 2011, 9:59 AM
hi jpcook01 (http://www.sencha.com/forum/member.php?300852-jpcook01)

thanks for your reply, but sorry i think you not understand my problem, iam able to set the value but unable to get the data in the first click of combobox in remote combo alone now.


As per skirtle and jgarcia post its working correctly for local store and iam unable to get it in remote queryMode..

As you said the problem may be in lastquery reset, I also think like that and tried already but its not working. may be iam not reset correctly.

vinodpadmanaban@gmail.com
5 Oct 2011, 11:55 AM
Hi skirtle and jgarcia ,

I had issue in remote pagination combo too, if it is related to this question ill continue with this thread or shall i close this thread(mark best answer) and continue in new one.