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

How to load form once combobox value is selected?

1 Answer 43 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 24 Jun 2019, 11:14 AM

Hi,

I have the following code:

<script>
Sys.Application.add_load(FormLoad) 
 
 function FormLoad()
 
  {
 
    HideOpportunity(true);
  
   
 
    function HideOpportunity(sender, eventArgs) {
  var x = document.getElementById("OpportunitySetUp");
   if (x.style.display === "none") {
    x.style.display = "block";
  } else {
    x.style.display =  "none";
  }
       
    var ForecastingGrid = document.getElementById("ForecastingRevenue");
   
     ForecastingGrid.style.display = "none";
 
     
    var RevenueForecasting  = $sq("[id$='cboRevenueForecasting']").val();
     
     if (RevenueForecasting == "Manual Phasing") {
        ForecastingGrid.style.display = "block";
    } else {
        ForecastingGrid.style.display = "none";
    }
     
  }
  </script>

 

This seems to work perfectly up until the combobox value is selected. The code only seems to execture and show the "ForcastingRevenue" section when "autopostback = true" is added to the combobox properties but this is useless as it refreshes the page of the form, resetting the other .style.display element of "OpportunitySetUp".

Is there a way to have the form load without adding in the autopostback property? I'm using the Cora Sequence framework if that is any use. 

 

Thanks for any help!

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 27 Jun 2019, 09:40 AM
Hi Adam,

Have you tried to cancel the postback:

Cancelling an Event
Several client-side events occur immediately before RadComboBox performs some action. Most of these events all have names that end with "-ing". You can use these events to cancel the RadComboBox's action by using the set_cancel method of the eventArgs passed to the handler:

JavaScript

function OnClientSelectedIndexChanging(sender, eventArgs) {
    eventArgs.set_cancel(true);
}

Another approach is to show the ForcastingRevenue for example in the OnClientSelectedIndexChanging event of the combobox.

If you need further assistance on this, please provide a sample reproduction page or its contents so that I can replicate the scenario and can work on it on my side.

Regards,
Rumen
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
ComboBox
Asked by
Adam
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or