This is a migrated thread and some comments may be shown as answers.

RadComboBox with checkbox - Unable to set checkbox on server side

9 Answers 593 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Andy
Top achievements
Rank 1
Andy asked on 27 Nov 2012, 08:54 PM
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

9 Answers, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 30 Nov 2012, 03:25 PM
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.
0
Andy
Top achievements
Rank 1
answered on 03 Dec 2012, 04:23 PM
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
0
Andy
Top achievements
Rank 1
answered on 03 Dec 2012, 05:11 PM
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
0
Kalina
Telerik team
answered on 06 Dec 2012, 01:35 PM
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.
0
Andy
Top achievements
Rank 1
answered on 06 Dec 2012, 10:35 PM

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
0
Cat Cheshire
Top achievements
Rank 1
answered on 11 Dec 2012, 05:34 PM

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.

0
duraid wadie
Top achievements
Rank 1
answered on 25 Jun 2014, 11:26 AM
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
0
Princy
Top achievements
Rank 2
answered on 25 Jun 2014, 01:02 PM
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.                       
0
duraid wadie
Top achievements
Rank 1
answered on 25 Jun 2014, 01:05 PM
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.
Tags
ComboBox
Asked by
Andy
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Andy
Top achievements
Rank 1
Cat Cheshire
Top achievements
Rank 1
duraid wadie
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or