In edit mode how to assign selected values in MultiCombo

  1. #1

    In edit mode how to assign selected values in MultiCombo

    Hello guys

    In my application most of the pages i used
    <ext:MultiCombo>
    It is working fine in add mode. While in edit mode i cannot assign selected values to that combo box. I can achieve that by using server side coding only.
    But in most of the times selected values are vanished. i am assigning values to that combo box in
    Page_Load(object sender, EventArgs e)
    event. once i clicked the combo box trigger means selected values are showing. Below mentioned code snippets i used.

    Store:

    <ext:Store ID="dsPackType" runat="server" AutoLoad="false" ShowWarningOnFailure="true">
            <Proxy>
                <ext:HttpProxy Url="/Lookup/GetPackType/" Timeout="6000000" />
            </Proxy>
            <Reader>
                <ext:JsonReader IDProperty="ID" Root="data" TotalProperty="total">
                    <Fields>
                        <ext:RecordField Name="ID" />
                        <ext:RecordField Name="VALUE" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
            <BaseParams>
                <ext:Parameter Name="Type" Value="1" />
            </BaseParams>
            <Listeners>
                <LoadException Handler="var win = winError;win.show();" />
            </Listeners>
            <SortInfo Field="VALUE" Direction="ASC" />
        </ext:Store>
    Page_load event: (Server side)

    
    var packtypeAll = editpdrraactivecontroller.GetPackTypeIDs(Convert.ToInt32(ViewData["id"].ToString()));
    
                            if (packtypeAll != null)
                            {
                                StringBuilder selectGroupName = new StringBuilder();
                                this.cboPackType.SelectionMode = MultiSelectMode.All;
                                foreach (var item in packtypeAll)
                                {
                                    SelectedListItem list = new SelectedListItem();
                                    list.Value = item.PACKTYPEID.ToString();
                                    this.cboPackType.SelectedItems.Add(list);
                                }
                            }
    Client Side:

    <ext:MultiCombo ID="cboPackType" StoreID="dsPackType" runat="server" Resizable="true"
                                    Width="200" ListWidth="200" ValueField="ID" DisplayField="VALUE" MsgTarget="Side">
    </ext:MultiCombo>
    Kindly help me how to achieve this in JavaScript code or which server side event i have to use.

    If above mentioned information not clear means please let me know.

    Thanks in advance.
  2. #2
    Hi,

    Please provide a full, but simplified, sample to reproduce the issue.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    Please provide a full, but simplified, sample to reproduce the issue.
    Hello Daniil

    Thanks for your quick update. i have created sample application for reproducing the same issue.
    You can get it from here.

    FYI

    Issues:

    In Edit mode values are selected but it is not displaying in Combo box. When i click the trigger it is showing.

    Kindly help me to fix this issue.

    Thanks in advance.
  4. #4
    It's very strange that you populate .SelectedItems in Page_Load, but the MultiCombo is populated with HttpProxy.

    HttpProxy makes a load request when a user clicks on trigger.

    I can suggest the following.

    1. AfterRender listener for the MultiCombo.
    <AfterRender Handler="this.onTriggerClick();" />
    2. Load listener for the Store.
    <Load Handler="#{cboPackType}.selectAll(); 
                   #{cboPackType}.blur(); 
                   #{cboPackType}.triggerBlur();" />
    3. Remove populating .SelectedItems code from Page_Load.
  5. #5
    Quote Originally Posted by Daniil View Post
    It's very strange that you populate .SelectedItems in Page_Load, but the MultiCombo is populated with HttpProxy.

    HttpProxy makes a load request when a user clicks on trigger.

    I can suggest the following.

    1. AfterRender listener for the MultiCombo.
    <AfterRender Handler="this.onTriggerClick();" />
    2. Load listener for the Store.
    <Load Handler="#{cboPackType}.selectAll(); 
                   #{cboPackType}.blur(); 
                   #{cboPackType}.triggerBlur();" />
    3. Remove populating .SelectedItems code from Page_Load.

    Hello Daniil

    Thanks for your quick update. Also sorry for my delayed reply.
    My case is i have to select multi combo box values based on database values. Unfortunately in your snippet i am not able to find that kind of code.
    I don't want to select all the values. That's y i used method in Page_load event.

    Step by Step debugging of Page_load method:

    var packtypeAll = editpdrraactivecontroller.GetPackTypeIDs(Convert.ToInt32(ViewData["id"].ToString()));
    1. Getting values from database and assign that values to variable.

     if (packtypeAll != null)
                            {
                                StringBuilder selectGroupName = new StringBuilder();
                                this.cboPackType.SelectionMode = MultiSelectMode.All;
                                foreach (var item in packtypeAll)
                                {
                                    SelectedListItem list = new SelectedListItem();
                                    list.Value = item.PACKTYPEID.ToString();
                                    this.cboPackType.SelectedItems.Add(list);
                                }
    }
    2. Checking object is null or not
    3. Select multi combo values based on database values.

    My issue is above code working fine. But when i am clicking multi combo trigger means then only selected values are appearing.
    So i am not sure whether i am using correct event or not.
    Kindly help me which event i have to use for select multi combo box items based on database values.

    If above information is not clear means please let me know.

    Thanks in advance.
  6. #6
    Try to use Load event of Store to select items.

Similar Threads

  1. Replies: 3
    Last Post: Jun 03, 2011, 12:10 PM
  2. Replies: 1
    Last Post: Jan 31, 2011, 7:45 AM
  3. Multicombo box not populating values in edit mode
    By vs.mukesh in forum 1.x Help
    Replies: 1
    Last Post: Jan 21, 2011, 8:26 AM
  4. Replies: 2
    Last Post: Sep 07, 2010, 7:42 AM
  5. [CLOSED] [1.0] Assign custom values to RadioGroup items
    By SandorD in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 22, 2010, 8:20 AM

Posting Permissions