Wednesday, April 16, 2014

How to talk to things outside of a DevExpress callback panel from within a callback panel.

I started something here and refined it here and then came up with the web form markup seen here. The markup below is a blob from that same markup with the items in white being new additions in one last revision:

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
   
<script type="text/javascript">
      function OnEndCallback(s, e) {
         if (s.cp_Arg) {
            var titleText = document.getElementById('TitleText');
            titleText.innerHTML = s.cp_Arg;
            titleText.style.color = "#FF0000";
            delete (s.cp_Arg);
         }
      }
      function UpdateTitleText() {
         var titleText = document.getElementById('TitleText');
         titleText.innerHTML = "These settings are up to date!";
         titleText.style.color = "#00FF00";
      }
   </script>

   <dx:ASPxCallbackPanel ID="SolorSystemCallBackPanel"
         OnCallback="SolarSystemCallBackPanel_Callback"
         ClientInstanceName="SolorSystemCallBackPanel" HideContentOnCallback="false"
         ShowLoadingPanel="true" EnableViewState="true" runat="server" Width="700px">
      <PanelCollection>
         <dx:PanelContent ID="SolorSystemContent" runat="server">
            <dx:ASPxGridView ID="SolarSystem" ClientInstanceName="SolarSystem"
                  runat="server" Width="100%" KeyFieldName="Name"
                  AutoGenerateColumns="False">
               
<ClientSideEvents EndCallback="OnEndCallback" />
               <SettingsBehavior AutoExpandAllGroups="True" />
               <SettingsPager PageSize="15">
               </SettingsPager>

 
 

You can probably see how the OnEndCallback stuff changes the copy inside of a div. Perhaps you can also imagine how the same trick might populate the value of a hidden field so that, when a form (the token form in a ASP.NET web form) is later posted, the value makes its way back to the server from the client. Anyways, my effect looks like this:

 
 

These two methods changed in the code behind. This is how I pass "This may no longer be current." and I have been told that any variables used must start with "cp_" or they won't work.

private void SolarSystem_RowInserting(object sender, ASPxDataInsertingEventArgs e)
{
   UseRevampedPlanets(RevampPlanets(new OrderedDictionary(), e.NewValues));
   e.Cancel = true;
   ((ASPxGridView)sender).JSProperties["cp_Arg"] = "This may no longer be current.";
}
 
private void SolarSystem_RowUpdating(object sender, ASPxDataUpdatingEventArgs e)
{
   UseRevampedPlanets(RevampPlanets(e.OldValues, e.NewValues));
   e.Cancel = true;
   ((ASPxGridView)sender).JSProperties["cp_Arg"] = "This may no longer be current.";
}

 
 

Finally, and less interestingly, I decorated both of the ASPxListBox's in Default.aspx's markup with an OnClick event like so:

<dxe:ASPxListBox ID="Distance" runat="server" ClientInstanceName="DistanceClient"
      Height="635" OnClick="UpdateTitleText()">

No comments:

Post a Comment