[CLOSED] How to change combobox store in javascript ?

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] How to change combobox store in javascript ?

    How can i Change combobox store in javascript??

    <%@ Page Language="C#" %>
    
    <%@ Import Namespace="System.Collections.Generic" %>
    <%@ Import Namespace="System.Xml" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            #region subjects
            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add("Subject_ID");
            dt.Columns.Add("subjectName");
            System.Data.DataRow drow = null;
            for (int i = 0; i < 4; i++)
            {
                drow = dt.NewRow();
                drow["Subject_ID"] = i;
                drow["subjectName"] = "Subject" + i.ToString();
                dt.Rows.Add(drow);
            }
            stsubject.DataSource = dt;
            stsubject.DataBind();
            #endregion
    
            #region Class
            System.Data.DataTable dt1 = new System.Data.DataTable();
            dt1.Columns.Add("class_ID");
            dt1.Columns.Add("ClassName");
            System.Data.DataRow drow1 = null;
            for (int c = 0; c < 4; c++)
            {
                drow1 = dt1.NewRow();
                drow1["class_ID"] = c;
                drow1["ClassName"] = "Class" + c.ToString();
                dt1.Rows.Add(drow1);
            }
            stClass.DataSource = dt1;
            stClass.DataBind();
            #endregion
    
    
    
        }
    </script>
    <head runat="server">
        <title>Local Paging for Remote Data - Ext.NET Examples</title>
        <script type="text/javascript">
            var Beforeshow = function (sender, e) {
                {
                    if (sender.trg.id.indexOf("ext-gen") == 0 || sender.trg.id == "") {
                        if (sender.trg.parentNode.id.indexOf("ext-gen") == 0 || sender.trg.parentNode.id == "") {
                            return false;
                        }
                    }
                }
            }
    
            var MenuClick = function (sender, e) {
                var comp = Ext.getCmp(sender.trg.id);
    
                if (comp != undefined) {
    
                    cbdF = Ext.getCmp("cbdynStore");
                    cbdF.initComponent();
                    if (cbdF != undefined) {
                        cbdF.store = comp.store;
                        cbdF.displayField = comp.displayField;
                        cbdF.valueField = comp.valueField;
                        cbdF.initialConfig.store = comp.store;
                        cbdF.initialConfig.displayField = comp.displayField;
                        cbdF.initialConfig.valueField = comp.valueField;
    
                    }
                    try {
                        Ext.getCmp("cbdynStore").view.store = comp.store;
                        Ext.getCmp("cbdynStore").view.refresh();
                    } catch (e) { }
    
                }
            };
        </script>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server">
        </ext:ResourceManager>
        <ext:Store ID="stsubject" IDMode="Static" runat="server">
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="Subject_ID" />
                        <ext:RecordField Name="subjectName" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
        </ext:Store>
        <ext:Store ID="stClass" IDMode="Static" runat="server">
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="class_ID" />
                        <ext:RecordField Name="ClassName" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
        </ext:Store>
        <ext:Menu ID="LoadStoreMenu" runat="server" IDMode="Static">
            <Items>
                <ext:CheckMenuItem ID="chbxStore" IDMode="Static" runat="server" Text="LoadStore">
                    <Menu>
                        <ext:Menu ID="mSotre" IDMode="Static" runat="server">
                            <Items>
                                <ext:ComboBox ID="cbdynStore" IDMode="Static" runat="server">
                                </ext:ComboBox>
                            </Items>
                        </ext:Menu>
                    </Menu>
                </ext:CheckMenuItem>
            </Items>
            <Listeners>
                <BeforeShow Fn="Beforeshow" />
                <Show Fn="MenuClick" />
            </Listeners>
        </ext:Menu>
        <ext:Panel ID="p1" runat="server" IDMode="Static" Frame="true" ContextMenuID="LoadStoreMenu">
            <Items>
                <ext:ComboBox ID="cbSubject" runat="server" IDMode="Static" FieldLabel="Subjects"
                    StoreID="stsubject" ValueField="Subject_ID" DisplayField="subjectName">
                </ext:ComboBox>
                <ext:ComboBox ID="cbClass" runat="server" IDMode="Static" FieldLabel="Class" StoreID="stClass"
                    ValueField="class_ID" DisplayField="ClassName">
                </ext:ComboBox>
            </Items>
        </ext:Panel>
        </form>
    </body>
    </html>
    Last edited by Daniil; Apr 09, 2013 at 3:51 AM. Reason: [CLOSED]
  2. #2
    Hi @imaa,

    Not 100% sure it will help, but you could try the bindStore method.
    http://docs.sencha.com/ext-js/4-2/#!...thod-bindStore

    Also could you explain why do you need to change the Store?
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @imaa,

    Not 100% sure it will help, but you could try the bindStore method.
    http://docs.sencha.com/ext-js/4-2/#!...thod-bindStore

    Also could you explain why do you need to change the Store?
    i need to do this for set default value configuration to comboxbox.
  4. #4
    So, does the bindStore method help?

    Quote Originally Posted by imaa View Post
    i need to do this for set default value configuration to comboxbox.
    Sorry, I didn't understand well. Do you need to set up a default value for a ComboBox?
  5. #5
    Quote Originally Posted by Daniil View Post
    So, does the bindStore method help?



    Sorry, I didn't understand well. Do you need to set up a default value for a ComboBox?
    yes i need to set up default value
  6. #6
    Can you not use a ComboBox's SelectedItems property to do that?
  7. #7
    Quote Originally Posted by Daniil View Post
    Can you not use a ComboBox's SelectedItems property to do that?
    No sir

    i need to do it like upper example with change store dynamically because i have in my system screen setup page ;
    so i need to make menu to setup permission and defualt value to page controls
  8. #8
    It is possible to set up a value for a ComboBox on the fly calling its setValue method. Is it not what you need?
  9. #9
    Quote Originally Posted by Daniil View Post
    It is possible to set up a value for a ComboBox on the fly calling its setValue method. Is it not what you need?
    no my friend

    i need to make setup page for system pages ; so when select the page from setup page i build a menu like example to set permission and default value ok
    the setValue method used when the original page load to set default value.
    now i want to check this case in example it's possibly to do ??
  10. #10
    I still don't understand well why you need to change the Store. But OK.

    Quote Originally Posted by imaa View Post
    now i want to check this case in example it's possibly to do ??
    What exactly?
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 0
    Last Post: Mar 27, 2013, 11:38 AM
  2. [CLOSED] How to dynamically change the url of combobox store
    By Daly_AF in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 16, 2013, 4:41 PM
  3. Replies: 1
    Last Post: Dec 15, 2012, 6:41 AM
  4. Replies: 2
    Last Post: Nov 01, 2012, 6:24 PM
  5. [CLOSED] change combobox store dynasmically
    By sisa in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Nov 22, 2011, 1:17 PM

Posting Permissions