469,319 Members | 2,339 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,319 developers. It's quick & easy.

How to populate combobox with data in extjs 2.3?

Here is my code for combobox which is in FormPanel:

Expand|Select|Wrap|Line Numbers
  1. var dept_names = [
  2.         ['1','Electronics and Communication'],
  3.         ['2','Electrical and Electronics'],
  4.         ['3','Telecommunication Engineering'],
  5.         ['4','Instrumentation and Electronics Engineering']
  6.     ];
  7.  Code for combobox in FormPanel: 
  8. {  
  9. xtype:'combo',
  10.  
  11.             fieldLabel:'Department Name',
  12.  
  13.             allowBlank:false,
  14.  
  15.             autoShow:true,
  16.  
  17.             id:'department',
  18.  
  19.             name:'department',
  20.  
  21.             emptyText:'Select the Department from the List',
  22.  
  23.             selectOnFocus:true,
  24.  
  25.             forceSelection:true,
  26.  
  27.             resizable:true,
  28.  
  29.             store: new Ext.data.SimpleStore({
  30.                   id:0,
  31.  
  32.                   autoLoad:true,
  33.  
  34.                     fields:
  35.                     [
  36.                         'deptId',   
  37.                         'deptName' 
  38.                     ]
  39.  
  40.                     ,data:dept_names
  41.  
  42.                 })
  43.  
  44.             ,valueField:'deptId'
  45.             ,displayField:'deptName'
  46.             ,hiddenName:'deptId'
  47.             ,mode:'local'
  48.  
  49. }
  50.  
When i run it i'm getting the combobox and getting emptyText also...
But the data given in the dept_names is not getting populated :(

Please do help me.
Thanks in advance.
May 5 '10 #1
3 8825
RamananKalirajan
607 512MB
Hi,
Here with I have attached a sample code. I created this one with Ext 2.1

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <link rel="stylesheet" type="text/css" href="ext-2.1/resources/css/ext-all.css" />
  4. <script type="text/javascript" src="ext-2.1/adapter/ext/ext-base.js"></script>
  5. <script type="text/javascript" src="ext-2.1/ext-all.js"></script>
  6. <link rel="stylesheet" type="text/css" href="ext-2.1/examples/shared/examples.css" />
  7.  
  8. </head>
  9. <body>
  10. <div>
  11.     Department Names: <input type="text" id="yourCombo">
  12.  </div>
  13.  <script type="text/javascript">
  14.  
  15. Ext.namespace('Ext.deptdata');
  16.  
  17. Ext.deptdata.dept = [['Electrionics and Communication', 'Electronics and Communication'],
  18.         ['Electrical and Electronics', 'Electrical and Electronics'],
  19.         ['Information technology', 'Information technology'],
  20.         ['TeleCommunication', 'TeleCommunication']];
  21.  
  22. var combo1 = new Ext.form.ComboBox({
  23.     store: Ext.deptdata.dept,
  24.     displayField:'deptName',
  25.     typeAhead: true,
  26.     mode: 'local',
  27.     triggerAction: 'all',
  28.     emptyText:'Select the Department from the List',
  29.     selectOnFocus:true,
  30.     applyTo: 'yourCombo'
  31. });
  32. </script>
  33. </body>
  34.  
  35. </html>
Thanks and Regards
Ramanan Kalirajan
May 5 '10 #2
Hello RamananKalirajan... I tried with the example you gave me, but still i'm not getting the drop down list. I checked for store getting data, its getting. I dont know why i'm not getting the drop down list. Can you tell me where i am going wrong.
Jun 2 '10 #3
RamananKalirajan
607 512MB
Please check for the path and everything. Post the code what you have tried and please let us know whether are you getting any exception

Thanks and Regards
Ramanan Kalirajan
Jun 2 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Jassim Rahma | last post: by
2 posts views Thread by Sean Holt via DotNetMonster.com | last post: by
11 posts views Thread by DSR | last post: by
16 posts views Thread by agrawal.solutions | last post: by
1 post views Thread by =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= | last post: by
1 post views Thread by =?Utf-8?B?Q2hyaXM=?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.