how to load combo box in asp.net MVC3??

  1. #1

    how to load combo box in asp.net MVC3??

    hi ,
    i want to load combox box with data whenever view is loaded is there any way to preloaded combobox when view is loaded i am using this code but its not working not loading any data . i am using asp.net MVC 3 aspx view engine.

    view code
    <ext:Store id="ClassStore"  runat="server"   AutoLoad="false" >
                                                                    <Model>
            <ext:Model ID="Model2" runat="server" IDProperty="id">
                <Fields>
                    <ext:ModelField Name="id" />
                    <ext:ModelField Name="title" />
                </Fields>
            </ext:Model>
        </Model> 
                                    <Proxy   > 
                                    <ext:AjaxProxy Url="/Data/getAll/" >                             
                                     <Reader>
                         <ext:JsonReader Root="Data" TotalProperty="TotalRecords" />
                     </Reader>
                                    </ext:AjaxProxy>
                                           </Proxy>
                                    </ext:Store>
    combo box code
    <ext:ComboBox ID="cmb"  runat="server" Editable="false" TypeAhead="true" QueryMode="Local"
                                 ColumnWidth="0.3"  StoreID="ClassStore"  DisplayField="title" 
                                    ValueField="id"   ForceSelection="true" Margin="2" TriggerAction="All" SelectOnFocus="true" EmptyText="Select a Class">
                                   
                                   
                                </ext:ComboBox>
    in my controller i have written this function

    /Data/getAll
    public StoreResult getAll() 
            {
                List<ClassBL> list;
    
              list = DB.GetAll();
                return new StoreResult(list , list .Count );
            }
    anybody guides me what is the right and best way to load combo box in asp.net MVC3?
    Last edited by Daniil; Mar 12, 2012 at 12:08 PM. Reason: Please use [CODE] tags
  2. #2
    Hi,

    You should not set up QueryMode="Local" if you need to load a remote data. So, please remove it or set up to "Remote".
    Last edited by Daniil; Mar 12, 2012 at 4:11 PM.
  3. #3

    yes you are awesome but also add this

    Quote Originally Posted by Daniil View Post
    Hi,

    You should not set up QueryMode="Local" if you need to load a remote data. So, please remote it ore set up to "Remote".
    yes thanks you that was the trick for combobox i add QueryMode="Remote" and i correct these properties Root="data" and TotalProperty="total"
    <Reader>
                         <ext:JsonReader Root="data" TotalProperty="total" />
                     </Reader>
    Last edited by Daniil; Mar 12, 2012 at 4:11 PM. Reason: Please use [CODE] tags

Similar Threads

  1. Ext.net with asp.net or MVC3 ?
    By GKG4 in forum 2.x Help
    Replies: 1
    Last Post: Aug 14, 2012, 4:06 PM
  2. Replies: 1
    Last Post: Jul 02, 2012, 6:19 PM
  3. [CLOSED] Load RadioGroup Item from database on Combo Select event
    By webclouder in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 16, 2010, 8:30 PM
  4. Replies: 0
    Last Post: Sep 04, 2009, 3:23 PM
  5. Load on demand combo box
    By jchau in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 03, 2008, 1:39 PM

Tags for this Thread

Posting Permissions