ComboBox items disappearing after reload

  1. #1

    ComboBox items disappearing after reload

    I'm hoping that someone has an idea of a workaround without having to post an example as my current page is somewhat complex (but the issue itself isn't).

    I have a page where users can create new drafts of a document, or select a draft that is already in progress. I'm using an Ext.Tool in the header of a panel that contains the ComboBox that holds the list of the drafts. If the user clicks the "Create New Draft" tool, the ComboBox reloads correctly (I'm reloading the store to contain the newly added draft to it), but once I expand the ComboBox, all items immediately disappear... but I can see that the store contains all of the correct values I expect... just no items to display in the dropdown. However, if the user expands the ComboBox prior to hitting the "Create New Draft" tool, everything behaves as I want. I just can't expect a user to expand the ComboBox first before adding a new draft every time. I tried giving the ComboBox focus and expanding/collapsing via JavaScript when the page loads, but that doesn't change anything (I was hoping that having it expand via JavaScript would give the same behavior as when the user expands it).

            Html.X().Panel()
                .ID("pnlDraftSelection")
                .UI(UI.Default)
                //.Frame(true)
                .Region(Region.North)
                .Layout(LayoutType.Border)
                .Border(true)
                .BorderSpec("0 0 1 0")
                .Height(75)
                .Title("Draft Selection")
                .Collapsible(true)
                .Tools(
                    Html.X().Tool()
                        .CustomType("add")
                        .ToolTip("Create New Draft")
                        .Listeners(li => li.Click.Handler = "openDraft(-1, -1, App.tabAdmin, 'idDraftDoc', 'Document Draft', '../Funnel/DraftDocument/', App.mItemDraftDoc);")
                )
                .Items(
                    Html.X().ComboBox()
                        .ID("cboDrafts")
                        .EmptyText("Select a Draft")
                        .MarginSpec("5 5 5 5")
                        .ValueField("DocKey")
                        .DisplayField("DocumentDisplay")
                        .ForceSelection(true)
                        .Region(Region.North)
                        .Flex(1)
                        .MaintainFlex(true)
                        .Store(Html.X().Store()
                            .ID("storeDrafts")
                            .DataSource(Model)
                            .AutoLoad(true)
                            .ServerProxy(
                                Html.X().AjaxProxy()
                                    .Url(Url.Action("_FunnelSideBar_GetDraftStore", "Funnel"))
                            )
                            .Model(
                                Html.X().Model()
                                    .Fields(
                                        Html.X().ModelField().Name("DocKey").Type(ModelFieldType.Int),
                                        Html.X().ModelField().Name("DocumentNumber").Type(ModelFieldType.String),
                                        Html.X().ModelField().Name("DocTitle").Type(ModelFieldType.String),
                                        Html.X().ModelField().Name("DocumentDisplay").Type(ModelFieldType.String)
                                    )
                            )
                        )
                        .Listeners(li =>
                        {
                            li.Select.Handler = "openDraft(this.getValue(), -1, App.tabAdmin, 'idDraftDoc', 'Document Draft', '../Funnel/DraftDocument/');";
                        })
                )
    Click image for larger version. 

Name:	DraftSelection.jpg 
Views:	76 
Size:	28.3 KB 
ID:	25256
  2. #2
    I was able to find a solution to my issue. By setting QueryMode to Local, I started getting the desired behvior.

                    Html.X().ComboBox()
                        .ID("cboDrafts")
                        .EmptyText("Select a Draft")
                        .MarginSpec("5 5 5 5")
                        .ValueField("DocKey")
                        .DisplayField("DocumentDisplay")
                        .ForceSelection(true)
                        .Region(Region.North)
                        .Flex(1)
                        .MaintainFlex(true)
                        .QueryMode(DataLoadMode.Local)
                        .Store(Html.X().Store()
                            .ID("storeDrafts")
                            .DataSource(Model)
                            .AutoLoad(true)
                            .ServerProxy(
                                Html.X().AjaxProxy()
                                    .Url(Url.Action("_FunnelSideBar_GetDraftStore", "Funnel"))
                            )
                            .Model(
                                Html.X().Model()
                                    .Fields(
                                        Html.X().ModelField().Name("DocKey").Type(ModelFieldType.Int),
                                        Html.X().ModelField().Name("DocumentNumber").Type(ModelFieldType.String),
                                        Html.X().ModelField().Name("DocTitle").Type(ModelFieldType.String),
                                        Html.X().ModelField().Name("DocumentDisplay").Type(ModelFieldType.String)
                                    )
                            )
                        )
                        .Listeners(li =>
                        {
                            li.Select.Handler = "openDraft(this.getValue(), -1, App.tabAdmin, 'idDraftDoc', 'Document Draft', '../Funnel/DraftDocument/');";
                        })
  3. #3
    Hello @craigthames!

    Thanks for taking the time to share also the solution you found for the issue you were facing, we really appreciate that!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Replies: 3
    Last Post: Jun 19, 2016, 6:21 PM
  2. Replies: 4
    Last Post: Jul 15, 2014, 10:59 AM
  3. [CLOSED] Reload dynamic menu items more than once
    By prost in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: May 03, 2014, 8:10 AM
  4. [CLOSED] Combo box items not loading on store reload.
    By Sowjanya in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Aug 20, 2013, 2:31 PM
  5. Replies: 5
    Last Post: Mar 15, 2013, 4:24 AM

Posting Permissions