Shared TimeView multiple TimePickers - custom action possible?

3 posts, 0 answers
  1. Andrew
    Andrew avatar
    39 posts
    Member since:
    Feb 2011

    Posted 14 Apr 2011 Link to this post

    I have a page with multiple TimePickers in a databound grid. They all share a TimeView to cut down on the HTML, but I need a button I've placed in the header template of the shared TimeView to 'clear' the value of the time picker I've clicked on (because a blank time has meaning for my application).

    The template is fine, I have my control in the header, but I'm not sure how to get access to the TimePicker that has been clicked in client side script to be able to set_selectedTime('');

    Any ideas?

    <edit>
    This page has exactly what I need - with the 'Clear' button in the footer - but the example code isn't for that image!

    http://www.telerik.com/help/aspnet-ajax/calendar-time-view.html
  2. Vasil
    Admin
    Vasil avatar
    1642 posts

    Posted 20 Apr 2011 Link to this post

    Hi Andrew,

    You can store a reference to the TimePicker which opened the TimePopup last time. And then on the button click to clear its value and hide the popup. See the example bellow:

    <script type="text/javascript">
     
      var LastTimePicker = null;
     
      function OnPopupOpening(sender, args) {
        LastTimePicker = sender;
      }
      function ClearAndClose(sender, args) {
     
        if (LastTimePicker != null) {
          LastTimePicker.clear();
          LastTimePicker.hideTimePopup();
        }
     
      }
    </script>
    <div>
      <telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource">
        <MasterTableView>
          <Columns>
            <telerik:GridTemplateColumn>
              <ItemTemplate>
                <telerik:RadTimePicker ID="RadTimePicker1" runat="server" SharedTimeViewID="SharedTimeView"
                  ClientEvents-OnPopupOpening="OnPopupOpening">
                </telerik:RadTimePicker>
              </ItemTemplate>
            </telerik:GridTemplateColumn>
          </Columns>
        </MasterTableView>
      </telerik:RadGrid>
      <telerik:RadTimeView ID="SharedTimeView" runat="server">
        <HeaderTemplate>
          <asp:Button runat="server" Text="Clear" ID="ClearButton" OnClientClick="ClearAndClose(); return false;" />
        </HeaderTemplate>
      </telerik:RadTimeView>
    </div>

    Best wishes,
    Vasil
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. Andrew
    Andrew avatar
    39 posts
    Member since:
    Feb 2011

    Posted 20 Apr 2011 Link to this post

    Thanks Vasil - that was almost identical to the solution I came up with!! Works well too... I love how easy these Telerik controls are to alter if they don't quite have the functionality you require... Thanks.
Back to Top