RadComboBox with checkbox - Unable to set checkbox on server side

10 posts, 0 answers
  1. Andy
    Andy avatar
    10 posts
    Member since:
    Jun 2012

    Posted 27 Nov 2012 Link to this post

    Hi,

    I am using RadComboBox control with checkbox.
    On "RadComboBox2_ItemsRequested" event, I need to set the checkbox for specific items in the combobox.

    Can somebody guide me how this can be achieved. I tried many different ways, but was unable to set the checkbox from server side on this event.

    Thanks
  2. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 30 Nov 2012 Link to this post

    Hi Andy,

    As far as I understand - you want to use the CheckBoxes feature of RadComboBox along with Load On Demand.
    I am afraid that this is not a supported scenario - please take a look at this help article.
    The RadComboBox items loaded via Load On Demand are not accessible at server-side.
    However the CheckBoxes feature needs to access the items at server-side - and that is why the simultaneous usage of these two features is not supported.


    Regards,
    Kalina
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Andy
    Andy avatar
    10 posts
    Member since:
    Jun 2012

    Posted 03 Dec 2012 Link to this post

    Hi,
    Thanks for the reply.

    Not sure why you say,
    "The RadComboBox items loaded via Load On Demand are not accessible at server-side."

    I am very well able to access the items on server side. For example whatever items checked before, I am able to reset the values to something else when it calls the routine for Load on Demand next time. Its just that the setting of the checkbox is not working.

    Is there any workaround for this issue, set the checkbox in load on demand.

    Thanks
  5. Andy
    Andy avatar
    10 posts
    Member since:
    Jun 2012

    Posted 03 Dec 2012 Link to this post

    If I can not use Radcombo with checkbox what is the best bet where I can allow multivalue select option?

    The functionality I am trying to achieve is,
    1. Allow multiselect values
    2. I should be able to get back all the selections on server side "Load On demand" when user clieck on the control again.

    Thanks
  6. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 06 Dec 2012 Link to this post

    Hello Andy,

    Regarding your last question - you can try using RadAutoCompleteBox.

    I am afraid that in order to provide you more precise answer I will need more details about your scenario
    What you mean by "I am very well able to access the items on server side"?
    How exactly do you access the RadComboBox items at server-side?
    Please paste here a working code that illustrates your implementation.

    Thank you in advance.


    Greetings,
    Kalina
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  7. Andy
    Andy avatar
    10 posts
    Member since:
    Jun 2012

    Posted 06 Dec 2012 Link to this post

    below is the code snippet I am using to achive the functionality.

    protected void RadComboBox2_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
    {
        int currGridIndex = myIndexofItemInEditMode;
        string mySelectedData = DataFields[currGridIndex].MyCriterion.ToString();
        RadComboBox propertyComboBox = (RadComboBox)rcItem.FindControl("RadComboBox2");
        int itemOffset = e.NumberOfItems;
        int endOffset = Math.Min(itemOffset + ItemsPerRequest, data.Rows.Count);
        e.EndOfItems = endOffset == data.Rows.Count;
        // check the box for previously selected items
        String[] myTmpArray = mySelectedData.Split(m_CharToSplit_pipe, StringSplitOptions.RemoveEmptyEntries);
        for (int i = itemOffset; i < endOffset; i++)
        {
            String currValue = data.Rows[i][myPropertySN].ToString();
            RadComboBoxItem myRItem = new RadComboBoxItem(currValue, currValue);
            myRItem.Checked = true;
            propertyComboBox.Items.Add(myRItem);
            rcItem.DataBind();
            if (myTmpArray.Contains("'" + currValue + "'"))
            {
                RadComboBoxItem item1 = propertyComboBox.SelectedItem;
                item1.Checked = true;
            }
        }
    }
    Here if I change the line from item1.Checked = true; to item1.Value = "Some Text";
    I am able to do that & for the previously selected fields the values are changed. But unable to check the previously selected check box.
    Please check the screen shot.
    Not sure if I have any confusing statments in my post. But I will be curious how AutoCompleteBox will help me achive the same. What I am trying to achieve is simple,
    - Get a RadComboBox style dropdown OR something like ListBox where users can select more than one value.
    Here are actual steps:
    - A RagGrid is displayed to the user.
    - When user click on "Edit" (renamed to "Filter") link it shows them the RadComboBox.
    - When they actually click on RadComboBox, I try to go grab data from datasource & attach to RaDCombo. & then they can select on the checkbox against each value in RadComboBox

    The problem is everytime they select some values in dropdown, & click update. If they want to comeback & check/uncheck any value. The RadComboBox resets all the selected values.
    What I am trying to achieve then is, get any previously selected values (check screenshots) everytime they click on ComboBox & recheck the previously selected checkbox. Please see the screenshot.

    Thank you
  8. Cat Cheshire
    Cat Cheshire avatar
    128 posts
    Member since:
    Jun 2010

    Posted 11 Dec 2012 Link to this post

    You can add some checked items in combo at ItemDataBound event of the grid:

        protected void OnItemDataBoundHandler(object sender, GridItemEventArgs e)
        {
            if (e.Item.IsInEditMode)
            {
                GridEditableItem item = (GridEditableItem)e.Item;

                if (!(e.Item is IGridInsertItem))
                {
                    RadComboBox combo = (RadComboBox)item.FindControl("RadComboBox1");

                    RadComboBoxItem checkedItem = new RadComboBoxItem();
                    selectedItem.Text = ((DataRowView)e.Item.DataItem)["Name"].ToString();
                    selectedItem.Value = ((DataRowView)e.Item.DataItem)["ID"].ToString();

                    combo.CheckedItems.Add(checkedItem);
                }
            }
       
    }


    However it is not good idea to use the LOD  and the checkboxes at the same time.

  9. duraid wadie
    duraid wadie avatar
    5 posts
    Member since:
    Jul 2009

    Posted 25 Jun 2014 in reply to Andy Link to this post

    Hi Andy,

    Just wondering if you ever got Combobox with check boxes and load on demand works after postback even if you have another solution that will be great. 

    Thanks
  10. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 25 Jun 2014 in reply to duraid wadie Link to this post

    Hi duraid wadie,

    CheckBox is not supported with Load On Demand . The reason is that RadComboBox's items loaded on demand are not  accessible on the server which is needed for the CheckBox feature. On Load on Demand from server side you can access only the Text and SelectedValue property.

    Thanks,
    Princy.                       
  11. duraid wadie
    duraid wadie avatar
    5 posts
    Member since:
    Jul 2009

    Posted 25 Jun 2014 in reply to Princy Link to this post

    Not sure why they can not just save the list once is loaded from the server and cached to the viewstate if you load the entire list not paged list.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017