Hello,
I have a Usercontrol with a RadComboBox that gets items via a webservice.
Everything is working correctly, however when I type, the search text disappears.
I had the same exact behavior with postbacks, but now its not posting back, and it is still doing the same thing.
Please take a look at the code below.
Here is the code for the RadComboBox:
Here is the code for CP_ItemChecked:
Here is the WebMethod:
I have a Usercontrol with a RadComboBox that gets items via a webservice.
Everything is working correctly, however when I type, the search text disappears.
I had the same exact behavior with postbacks, but now its not posting back, and it is still doing the same thing.
Please take a look at the code below.
Here is the code for the RadComboBox:
<
telerik:RadComboBox
ID
=
"cboContentProvider"
runat
=
"server"
Width
=
"225px"
CheckBoxes
=
"true"
EmptyMessage
=
"-- Select --"
EnableLoadOnDemand
=
"True"
ShowMoreResultsBox
=
"True"
OnClientItemChecked
=
"ItemChecked"
EnableVirtualScrolling
=
"True"
>
<
WebServiceSettings
Method
=
"GetContentProviderData"
Path
=
"../../WebService/BoomboxWs.asmx"
/>
<
ExpandAnimation
Type
=
"InOutElastic"
/>
</
telerik:RadComboBox
>
Here is the code for CP_ItemChecked:
function
CP_ItemChecked(sender, eventArgs) {
var
data =
'{ "type": "'
+ sender.get_id() +
'", "id": "'
+ eventArgs.get_item().get_value() +
'" }'
;
$.ajax({
type:
"POST"
,
url:
"../../WebService/BoomboxWs.asmx/MarkSelectedItem"
,
data: data,
contentType:
"application/json; charset=utf-8"
,
dataType:
"json"
,
success:
function
(msg) {
}
});
}
Here is the WebMethod:
[WebMethod(EnableSession =
true
)]
public
RadComboBoxData GetContentProviderData(RadComboBoxContext context)
{
return
GetRadComboBoxData(context, DtCp, DtCp.Count());
}
public
RadComboBoxData GetRadComboBoxData(RadComboBoxContext context, List<GenericDataList> data,
int
itemsPerRequest = 20)
{
var comboData =
new
RadComboBoxData();
var itemOffset = context.NumberOfItems;
var endOffset = itemOffset + itemsPerRequest;
if
(endOffset > data.Count())
{
endOffset = data.Count();
}
if
(!
string
.IsNullOrEmpty(context.Text))
{
data = data.Where(q => q.Name.ToUpper().Contains(context.Text.ToUpper())).ToList();
}
comboData.EndOfItems = endOffset == data.Count();
var result =
new
List<RadComboBoxItemData>(endOffset - itemOffset);
result.AddRange(data.Take(endOffset).Skip(itemOffset)
.Select(radItem =>
new
RadComboBoxItemData {Text = radItem.Name, Value = radItem.Id.ToString(CultureInfo.InvariantCulture)}));
comboData.Message = data.Any() ? String.Format(
"Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>"
, endOffset, data.Count()) :
"No matches"
;
comboData.Items = result.ToArray();
return
comboData;
}