Populate Ext JS ComboBox using data from MySql
January 6th, 2009
Here is my code
var friendsData = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({url : $baseUrl+'feed_actions.php'}),
reader : new Ext.data.JsonReader(['friendid','friend_name']),
remoteSort : false
});
this.cbo_type = new Ext.form.ComboBox({
id: 'cbo_type',
fieldLabel: 'Select Share Type',
width: 240,
readOnly:true,
valueField:'friendid',
displayField:'friend_name',
validationEvent: false,
validateOnBlur: false,
msgTarget: 'under',
triggerAction: 'all',
displayField: 'url',
mode: 'local',
listeners:{
valid: this.syncShadow,
invalid: this.syncShadow,
scope: this
},
tpl: new Ext.XTemplate(
'
'{url}{text}',
'
Generally, we can help you with questions specific to Ext and/or examples, however, it is out of the scope of this forum to develop or design user's applications. The best advice would be: design your application (its purpose, identify components needed, layout, UI), start coding, study example and API docs and when you run into an Ext specific problem we're ready and willing to help.
While am using combo.setValue(id) to sets the default value, it will showing the value as selected on combo box during the loading time of form, but the issue is the remaining items of the list are not listed when i use the setValue(id).
this.cbo_type = new Ext.form.ComboBox({
id: 'cbo_type',
width: 240,
readOnly:true,
validationEvent: false,
validateOnBlur: false,
msgTarget: 'under',
//triggerAction: 'all',
valueField:'url',
displayField:'text',
fieldLabel: 'Select Share Type',
mode: 'local',
listeners:{
valid: this.syncShadow,
invalid: this.syncShadow,
scope: this
}
/*,tpl: new Ext.XTemplate(
'
'{url}{text}',
'
The version whixch i am working with is ExtJs 2.0.
While i am trying with previous version, am getting the values on the dropdown and which is working correctly. So please give an idea for the same to works with the ExtJs 2.0
Regards
Shameer
Can u explain me in some details...
The issue which i am facing is am not getting value in the drop-down, instead an error (this.store has no properties) is getting on the firebug.
Can you please update me why it is happening? Take your time and Please help me.
Regards
Shameer
Take a look please and should you have more questions just keep asking.
Thanks for your last postings, which are helped me.
While am trying to populate the combobox with data from mysql table.
It is showing an error : 'this.store has no properties'
The Response which is getting to me on firbug is :
{"friendid":"1","friend_name":"news"},{"friendid":"8","friend_name":"zane"},{"friendid":"19","friend_name"
:"company"},{"friendid":"100","friend_name":"joban123"}
the code which i am using to get data from server is(php code) :
($friends is an array of fields.)
if(is_array($friends)){
foreach ($friends as $friend){
$friends_data = array('friendid'=>$friend->friendid,'friend_name'=>$friend->friend_name);
}
}
echo json_encode($friends_data);
return;
The JS code which am using is:
ShareWindow = function() {
this.cbo_friends = new Ext.form.ComboBox({
id: 'cbo_friends',
fieldLabel: 'Share Item to Friends',
width: 240,
readOnly:true,
validationEvent: false,
validateOnBlur: false,
msgTarget: 'under',
triggerAction: 'all',
valueField:'friendid',
displayField:'friend_name',
mode: 'remote',
listeners:{
valid: this.syncShadow,
invalid: this.syncShadow,
scope: this
},
tpl: new Ext.XTemplate(
'
'{url}{text}',
'
I have to pre-populate dropdown with values from database. How can be it possible?
My code for combobox is
this.cbo_type = new Ext.form.ComboBox({
id: 'cbo_type',
fieldLabel: 'Select Share Type',
width: 240,
readOnly:true,
validationEvent: false,
validateOnBlur: false,
msgTarget: 'under',
triggerAction: 'all',
displayField: 'url',
mode: 'local',
listeners:{
valid: this.syncShadow,
invalid: this.syncShadow,
scope: this
},
tpl: new Ext.XTemplate(
'
'{url}{text}',
'
If i have more than one node for a tree panel,
is there any option to reload only one node?
node.reload() showing error : node.reload is not a function
where as name of my node is 'node' then also it shows error
In the docs i didn't get any notes for reload().There list no event/methods with reload() for tree panel, Can u help me please
thanks in advance
regards
Shameer
I have to get refreshed the feed panel, where i have a code which is similar to ExtJs exampls feed-viewer. If i have number of nodes and i added a new item to a particular node and my requirement is to reload the content of the selected node with the newly added item.
How can i possible this to do ? Please help me
I am getting the values from database to drop down with the ext_all.js with earlier version. But am not getting th e values to combo-box while i am trying with the ExtJs 2.0.
While using ExtJs2.0 getting error @ firebug : The error is:this.store has no properties
What is the wrong with this code ?
Regards,
Thank you very much for all of your great help.
I could go a bit further, and can send and receive data json_encoded data from the server. But we get an error while we click on the drop down control. The JS code is as follows,
ShareWindow = function() {
var cbo_friends = new Ext.form.ComboBox({
fieldLabel: 'Share Item to Friends',
store:loadFriends,
valueField:'friendid',
displayField:'friend_name',
mode: 'remote',
minChars : 0
});
var friends_data = new Ext.data.JsonReader({
totalProperty: "totalCount",
root: "rows",
id: "id"
}, [ 'friendid', 'friend_name']);
var loadFriends = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: $baseUrl+"feed_actions.php?action=load_todrop"
}),
reader: friends_data,
remoteSort: false
});
var fp = new Ext.FormPanel({
labelAlign:'top',
items:[cbo_friends],
border: false,
bodyStyle:'background:transparent;padding:10px;'
});
loadFriends.load();
ShareWindow.superclass.constructor.call(this, {
title: 'Share Item',
iconCls: 'feed-icon',
id: 'add-feed-win',
autoHeight: true,
width: 280,
resizable: false,
plain:true,
modal: true,
y: 100,
autoScroll: true,
items: fp
});
this.addEvents({add:true});
}
Ext.extend(ShareWindow, Ext.Window, {
show : function(feed_data){
ShareWindow.superclass.show.apply(this, arguments);
}
});
and the json encoded reply is
{"success":true,"totalCount":4,"rows":[{"friendid":"1","friend_name":"news"},{"friendid":"8","friend_name"
:"zane"},{"friendid":"19","friend_name":"company"},{"friendid":"100","friend_name":"joban123"}]}
.
Can you please help to get the returned data loaded into the ComboBox.
Thank you in advance,
Lovegin
Thanks .You guided me to the exact track in Combo-box populating issue.
Regards, Shameer
The issue which i have with the feed-viewer is as follows.
The JS and PHP,CSS are all same as that on which given on feed-viewer example. Here what am i required is to reload/refresh the left side feed panel (Where all feeds which are listed on a tree under "My Feeds"). when ever i add a new Feed. On this case in which file i have to code for reloading the tree ?
How is it possible?
can u help me please ?
In my code am using mysql data to list feeds on panel .
I think in the feed-viewer example the following code placing the feed on the panel temporarily.
return this.fireEvent('validfeed', {
url: url,
text: text,
description: description
});
So how can i refresh the left side feed panel while adding a new feed ?
Because my current requirement will satisfy only with refreshing the left-side feed panel
Thanks in advance
Shameer
#If you have any other info about this subject , Please add it free.# |
Posted in freedeadaim.com | edit
A little something about you, the author. Nothing lengthy, just an overview.