[CheckedDropDownList] Load-on-Demand

1 Answer 111 Views
CheckedDropDownList
Kamil
Top achievements
Rank 1
Iron
Kamil asked on 15 Oct 2021, 09:13 AM

I want to implement my own version of load on demand feature for RadCheckedDropDownList (if there's already one that meets my requirements then sorry for posting).

When the RadCheckedDropDownList's  OnKeyUp event happens for alphanumeric char I want to send async request to my ASP.NET Web Service - when webservice's request is completed I want to either (both options are viable for me):

a) add new items (that are not already existing) to the DataSource,

b) save somewhere items that are already checked and load items to the DataSource,

and show Popup scrolled to the item that is matching the text that already user inserted into RadCheckedDropDownList's RadCheckedDropDownListEditableAreaElement.

My code so far:


private void LoadOnDemandCompleted( object sender, GetDropDownMenuItemsPagedCompletedEventArgs e )
{
	//RadCheckedDropDownListOnDemand - my class that inherits RadCheckedDropDownList
	if ( e.Error != null || e.Result == null || (int)e.UserState != this.RadCheckedDropDownListOnDemand.RequestId )
	{
		//WS call errored out, nothing was returned, or the request number is not matching
		return;
	}

	if ( !( this.RadCheckedDropDownListOnDemand.DataSource is List<RadCheckedListDataItem> mainDataSource ) )
		return;

	//Properties explanation:
	//Value == string to display
	//Id == id in database
	//ChoiceOrder - order in which the RadCheckedListDataItem should appear -> lower ChoiceOrder means it is higher on the list

	var itemsFiltered = e.Result.Select( re => new RadCheckedListDataItem( re.Value )
	{
		Value = re.Id,
		Tag = re.ChoiceOrder,
	} )
	.Where( item => !mainDataSource.Any( mainDataSourceItem => (int)item.Value == (int)mainDataSourceItem.Value ) )
	.ToList();

	//don not want to add items that are already existing in 
	if ( itemsFiltered.Count > 0 )
	{					
		mainDataSource.AddRange( itemsFiltered );

		//want to refresh item list for CheckedDropDownListElement
		if ( !( this.RadCheckedDropDownListOnDemand.CheckedDropDownListElement.DataSource is List<RadCheckedListDataItem> listElementDataSource ) )
			return;

		listElementDataSource.AddRange( itemsFiltered );

		//this does not show the newly added items
		this.RadCheckedDropDownListOnDemand.CheckedDropDownListElement.ShowPopup();				
	}
}

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 18 Oct 2021, 12:24 PM
Hello, Kamil,


RadCheckedDropDownList doesn't offer load on demand functionality. However, I can suggest you to use a RadPopupEditor control instead and host a RadVirtualGrid in its popup. RadVirtualGrid loads its data on demand. Hence, it would be a perfect fit for your scenario. It also supports creating custom columns so you can achieve the checkbox column: 

https://docs.telerik.com/devtools/winforms/controls/virtualgrid/cells/creating-custom-cells

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Kamil
Top achievements
Rank 1
Iron
commented on 19 Oct 2021, 10:09 AM

Thanks for answering. Unfortunately I don't think this solution will be sufficient to me.
Here's what I need for the end user - someting like multi-select RadCheckedDropDownList, where user types data in TextBox. After pressing one letter or number the control is loading async X items that are matching the currently typed text and are shown in dropdown part with checkboxes. If user fully enters the specific item's Text and pressed ";" or TAB key, then it is selected and can type new item with the same actions as in the first case.

Is this requirement possible with using Telerik controls? I thought about combining / mixing RadCheckedDropDownList, RadVirtualGrid, MultiColumnComboBox and / or PopupEditor but I don't think any combination of those controls will work.
Dess | Tech Support Engineer, Principal
Telerik team
commented on 21 Oct 2021, 09:53 AM

Hello, Kamil,

RadVirtualGrid is the closest control to the load on demand functionality that you need. If you place it inside a RadPopupEditor as it was suggested in my previous reply, it would be as close as possible to the requirement that you are trying to achieve with the Telerik UI for WinForms suite:
https://docs.telerik.com/devtools/winforms/controls/virtualgrid/working-with-data/virtualgrid-populating-with-data 
https://docs.telerik.com/devtools/winforms/controls/editors/popupeditor/getting-started

As to the checkboxes functionality, you can integrate it as a custom checkbox column in the virtual  grid: https://docs.telerik.com/devtools/winforms/controls/virtualgrid/cells/creating-custom-cells    

Thus, when you type in the editable part of RadPopupEditor, you can fetch the relevant data and refresh the RadVirtualGrid with the filtered data using its CellValueNeeded event. Please make sure that you update the RowCount and ColumnCount accordingly. However, the tokens are not available in this case.

Alternatively, you can use RadAutoCompleteBox for the handling the input with tokens in combination with RadVirtualGrid for visualizing the relevant data. It is up to you to choose this approach which suits your scenario best.
Should you have further questions please let me know.

 
Tags
CheckedDropDownList
Asked by
Kamil
Top achievements
Rank 1
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or