PDA

View Full Version : Ext.form.Select



Riaz
29 May 2011, 6:02 AM
How do I call " Ext.data.Store" when I tap "Ext.form.Select"



var Select_SubprojectStore = new Ext.data.Store({
storeId: 'patientStore',
model: 'Select_SubProject123',
autoLoad: true,
proxy: {
type: 'ajax',
url: BASE_APP_URL + 'Project/SubProjects',
reader: {
type: 'json',
root: 'data'
}
}

});





var SubprojectSelectField = Ext.extend(Ext.form.Select, {
required: true,
name: 'SubprojectName',
label: 'Subproject',
valueField: 'SubprojectCount',
displayField: 'SubprojectName',
store: Select_SubprojectStore,

listeners: {
render: function () {
Select_SubprojectStore.load();
},
click: function () {
// which event do I use to call 'Select_SubprojectStore' after tap 'Ext.form.Select' ???????????????
}
}
});


Please give me a clue.

Riaz
29 May 2011, 4:38 PM
Is it possible to call 'Ext.data.Store' after click/tap 'Ext.form.Select'?

tomalex0
29 May 2011, 9:40 PM
Hi,

I think select field doesn't have click or tap listener.

If you look into the change event of selectfield, we can try something like this


listeners :{
change : function(select,value){
console.log(select.store) //this gives store bound to selectfield
}
}

Riaz
29 May 2011, 10:20 PM
Hi,

I think select field doesn't have click or tap listener.

If you look into the change event of selectfield, we can try something like this


listeners :{
change : function(select,value){
console.log(select.store) //this gives store bound to selectfield
}
}


Thanks for your reply.

What I am trying to do-

It is a child "selectfield". I want to do load data after select filed is taped. What should I do?

tomalex0
29 May 2011, 10:30 PM
listeners : {
afterrender : function(cmp){
cmp.mon(cmp.el, {
tap: function(){
console.log(cmp.store.getCount());
}
});
}
}

add listener for selectfield like this.

Riaz
29 May 2011, 10:43 PM
Do you say link this -



var SubprojectSelectField = Ext.extend(Ext.form.Select, {
required: true,
name: 'SubprojectName',
label: 'Subproject',
valueField: 'SubprojectCount',
displayField: 'SubprojectName',
store: Select_SubprojectStore,
listeners: {

//render: function () {
// Select_SubprojectStore.load();

// }
// ,

afterrender: function (cmp) {
cmp.mon(cmp.el, {
tap: function () {
//console.log(cmp.store.getCount());
Select_SubprojectStore.load();
}
});
}

}
});




Now tap event is working. But when I change the value, it is not showing on 'displayField'.

tomalex0
29 May 2011, 10:47 PM
How your Model looks?

Riaz
29 May 2011, 10:51 PM
Ext.regModel('Select_SubProject123', {
fields: ['SubprojectCounter', 'ProjectCounter', 'SubprojectName']
});




var Select_SubprojectStore = new Ext.data.Store({
storeId: 'patientStore',
model: 'Select_SubProject123',
autoLoad: true,
proxy: {
type: 'ajax',
url: BASE_APP_URL + 'Project/xyz',
reader: {
type: 'json',
root: 'data'
},
actionMethods: {
read: 'POST'
}
}

});





var SubprojectSelectField = Ext.extend(Ext.form.Select, {
required: true,
name: 'SubprojectName',
label: 'Subproject',
valueField: 'SubprojectCount',
displayField: 'SubprojectName',
store: Select_SubprojectStore,
listeners: {

//render: function () {
// Select_SubprojectStore.load();

// }
// ,

afterrender: function (cmp) {
cmp.mon(cmp.el, {
tap: function () {
//console.log(cmp.store.getCount());
//Select_SubprojectStore.load();
cmp.store = Select_SubprojectStore.load();
}
});
}

}
});



do I design correctly?

tomalex0
29 May 2011, 11:33 PM
your valuefield is mentioned as SubprojectCount, but it is not mentioned in model?

Riaz
29 May 2011, 11:46 PM
Thank you very much brother for correction my mistake. It is working now. I am very grateful to you.


However, still I have a issue. how do I refresh my 'Select_SubprojectStore' after ' afterrender' event?

Basically 'Select_SubprojectStore' will store after tab on 'Ext.form.Select'. Have you got my point?

Riaz
30 May 2011, 1:46 AM
Desperately looking help.

Riaz
30 May 2011, 5:12 PM
With the help of the Sencha touch brothers, I have solved the issue. Any comment will be appreciated.



var Select_SubprojectStore = new Ext.data.Store({
storeId: 'patientStore',
model: 'Select_SubProject123',
autoLoad: true,
proxy: {
type: 'ajax',
url: BASE_APP_URL + 'Project/SubProjects',
reader: {
type: 'json',
root: 'data'
}
}
, autoLoad: true

, listeners: {
beforeload: function (store, operation) {
alert('beforeload is working');
var currentProjectCounter = controllers_GlobalVaiables.CurrentHoldingProjectCounter;
operation.params = {
ProjectCounter: currentProjectCounter
}
}
} //[END- Listener]
});






var SubprojectSelectField = Ext.extend(Ext.form.Select, {
required: true,
name: 'SubprojectName',
label: 'Subproject',
valueField: 'SubprojectCounter',
displayField: 'SubprojectName',
store: Select_SubprojectStore,
listeners: {
afterrender: function (cmp) {
cmp.mon(cmp.el, {
tap: function () {
Select_SubprojectStore.load();
}
});
}

}
});