Values added to store(inside Ext Window) are lost when lightbox(Ext Window) is shown for the first time after page load

  1. #1

    Values added to store(inside Ext Window) are lost when lightbox(Ext Window) is shown for the first time after page load

    Hi,
    I am using an Ext Window as light box which is having a combo box and store. The data source for the combo box is the store.
    I add records to the above store(store with ID "LightboxStore") while opening the light box(Please see the functions "OpenLightbox()" and "syncLightBoxStores()"). But the items added to the store are disappearing while the light box is shown for the first time. Afterwards it works fine. This problem is happening only for the first time when showing the lightbox for the first time ,after the page loads.(After first time i am able to add records to the store successfully and gets reflected in the combo box in the light box)


    <ext:Window Hidden="true" AutoScroll="true" AutoHeight="true" Width="356px" Closable="true"
        HideParent="true" Modal="true" Resizable="false" Header="false" runat="server"
        Shadow="Frame" ID="tswindow">
        <Content>
            <div id="divUserControl">
                <ext:Store ID="LightboxStore" OnSubmitData="SaveData" runat="server">
                    <Reader>
                       <ext:ArrayReader>
                         <Fields>
                             <ext:RecordField Name="Name" Type="String" />
                             <ext:RecordField Name="Type" Type="String" />                         
                        </Fields>
                    </ext:ArrayReader>
                 </Reader>
                </ext:Store>
            </div>
        </Content>
        <Listeners>
            <Hide Fn="lightboxCloseCallback" />
        </Listeners>
    </ext:Window>
    
    //I needed to add a few records to the lightbox store( these records needed to be binded to a combo box list in the lightbox which I have not provided in //the code above)
    
    //I'm using a function like the below to add records to the lightbox store
    //this function gets called in the OpenLightbox() method which open the light box
    function syncLightBoxStores() {
            var store1 = getStore1();        
            AddRecords(store1.data.items);        
        }
    
    //I am calling the syncLightBoxStores() when opening the lightbox
    //Function to open light box
    
    function OpenLightbox(lightBoxId) {    
        
            syncLightBoxStores();
            var window = Ext.getCmp(lightBoxId);
            window.show();// showing lightbox
            
        }
    
    function AddRecords(records) {        
            var store = getStore(getLightBoxStoreId()); // i'm able to get the lightbox store and add records successfully
    for (var i = 0; i < records.length; i++) {
                    var rc = records[i];
                    var data = { Name: rc.get("Name"), Type: rc.get("Type")};
                    store.addRecord(data);// adding records successful
             }
             store.commitChanges();
        }

    Any helps are really appreciated
    Regards
    Jophin
    Last edited by Daniil; Oct 11, 2011 at 4:33 PM. Reason: Please use [CODE] tags
  2. #2
    I don't see your combo
    Did you set Mode="Local" and TriggerAction="All" for the combo?
  3. #3

    It solved the problem

    Quote Originally Posted by Vladimir View Post
    I don't see your combo
    Did you set Mode="Local" and TriggerAction="All" for the combo?
    Thanks Vladimir it fixed my problem.

    I added Mode="Local" TriggerAction="All"

    <ext:ComboBox ID="ddlComponents" runat="server" StoreID="LightboxStore" EmptyText="Select Component"
                                        DisplayField="InstanceName" ValueField="Type" MinChars="1" ListWidth="300" TypeAhead="true"
                                        ForceSelection="true" ItemSelector="tr.list-item"
    
     Mode="Local" TriggerAction="All">  //here
    
                                        <Template ID="Template1" runat="server">
    <Template ID="Template1" runat="server">
    </Template>
    </ext:ComboBox>
    Again thank you very much for the quick reply

    Regards
    Jophin
    Last edited by Daniil; Oct 11, 2011 at 4:34 PM. Reason: Please use [CODE] tags

Similar Threads

  1. Replies: 1
    Last Post: Jun 18, 2012, 3:41 PM
  2. [CLOSED] Window inside an aspx page that is loaded in a TAB
    By Hari_CSC in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 06, 2010, 8:34 AM
  3. Open window on page load
    By Kamal in forum 1.x Help
    Replies: 4
    Last Post: Nov 04, 2009, 10:49 AM
  4. Replies: 1
    Last Post: May 17, 2009, 6:06 PM
  5. Open a window and load a page with Javascript
    By Neeraj Sharma in forum 1.x Help
    Replies: 2
    Last Post: Jan 17, 2009, 1:12 AM

Posting Permissions