I want to show an ajax loader processing icon when i click the drop down button of a Rad Combobox and it should be hidden when the drop down items are displayed. I tried doing with the onclientdropdownopening and onclientdwnopened ropdoproperties of the combobox but still I was not able to get the desired results. Can anyone help me out with this???
9 Answers, 1 is accepted
If the RadComboBox has load on demand enabled, it's advisable to show the loading panel when the OnClientItemsRequesting event is fired and hide it on the OnClientItemsRequested event.
Regards,
Dimitar Terziev
the Telerik team
Thank you for the hint. It will be very useful if you provide me with a demo since I am very much new to this field.
Please take look into the Demo I tried.
ASPX:
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
EnableAJAX
=
"true"
DefaultLoadingPanelID
=
"RadAjaxLoadingPanel1"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadComboBox2"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadComboBox2"
LoadingPanelID
=
"AjaxLoadingPanel1"
>
</
telerik:AjaxUpdatedControl
>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel1"
Transparency
=
"80"
MinDisplayTime
=
"300"
runat
=
"server"
>
<
asp:Image
ID
=
"l"
runat
=
"server" ImageUrl="~/Images/LoadingPanelImage1.gif"
AlternateText
=
"Loading"
/>
</
telerik:RadAjaxLoadingPanel
>
<
telerik:RadComboBox
ID
=
"RadComboBox2"
runat
=
"server"
EnableLoadOnDemand
=
"True"
ShowMoreResultsBox
=
"true"
OnItemsRequested
=
"RadComboBox2_ItemsRequested"
OnClientItemsRequesting
=
"ClientItemsRequesting"
OnClientItemsRequested
=
"ClientItemsRequested"
>
</
telerik:RadComboBox
>
Javascript:
<script type=
"text/javascript"
>
function
ClientItemsRequesting(sender, args) {
var
loadingPanel = $find(
"<%= RadAjaxLoadingPanel1.ClientID %>"
);
loadingPanel.show(sender.get_id());
}
function
ClientItemsRequested(sender, args) {
var
loadingPanel = $find(
"<%= RadAjaxLoadingPanel1.ClientID %>"
);
loadingPanel.hide(sender.get_id());
}
</script>
Thanks,
Princy.
That was really helpful.. Thank you so much..
I need another customization here. Below is my code for RadComboBox control
<telerik:RadComboBox ID="ComboID" runat="server" Width="150" Height="200" AllowCustomText="true" EnableItemCaching="false" EnableAutomaticLoadOnDemand="true" ItemsPerRequest="25" OnClientItemsRequesting="ClientItemsRequesting" OnClientItemsRequested="ClientItemsRequested">
</telerik:RadComboBox>
I am not using any server side code to load the combo items. As seen above, the client side event "ClientItemsRequesting" will load the combo items using AJAX request. Can you let me know, how to show the busy loading icons in this case
I would suggest you to consider the approach where the LoadingPanel is shown in the OnClientItemsRequesting event handler and then it is hidden in the success handler of the Ajax request.
Regards,
Peter Milchev
Telerik by Progress
I tried with this approach, but LoadingPanel doesn't show up.Find the below code written in client side,
function ClientItemsRequesting(sender, args) {
var text = sender.get_text();
sender.get_items().clear();
var id = sender.get_id();
var index = id.indexOf('ComboBox');
////Loading Panel
var loadingPanel = $find("RadAjaxLoadingPaneStreamer");
if(loadingPanel){
loadingPanel.show();
}
var myVar = GetComboItems(text, id, id.substr(0, index) + "Filter");
args.set_cancel(true);
}
function GetComboItems(text, comboId, method) {
var streamerFilterDto = GetFilterValues(text);
var data = {};
data = JSON.stringify(streamerFilterDto);
$.ajax({
url: "WebService/GetData.ashx/" + method,
type: 'POST',
method: 'POST',
contentType: "application/json",
async: false,
cache: false,
data: data,
success: function (result) {
if (result) {
var comboInstance = $find(comboId);
if (comboInstance) {
comboInstance.clearItems();
var items = comboInstance.get_items();
comboInstance.trackChanges();
var comboItem;
$.each(result, function (index, item) {
comboItem = new Telerik.Web.UI.RadComboBoxItem();
comboItem.set_text(item.Text);
comboItem.set_value(item.Value);
items.add(comboItem);
});
comboInstance.commitChanges();
}
}
////Loading Panel
var loadingPanel = $find("RadAjaxLoadingPaneStreamer");
if(loadingPanel){
loadingPanel.hide();
}
}
});
}
Please find attached a sample project that we created based on the described approach and used to record this screencast.
To simulate the server we have used json-server. In order to run it, you should install json-server, open a command prompt in the folder where the db.json is located, enter the json-server --watch db.json command. Then you will have a server listening on http://localhost:3000.
Regards,
Peter Milchev
Telerik by Progress
Thanks a lot for the solution. At my end, the property "EnableLoadOnDemand=true" was missing for RadCombo.
Also data from ajax request used to take some time, so I added timeout delay as below which shows the panel for combo item requesting event...
setTimeout(function () {
GetComboItems(text, id, filterMethod, sender);
}, 2000);