This is a migrated thread and some comments may be shown as answers.
Shared TimeView multiple TimePickers - custom action possible?
2 Answers 18 Views
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 14 Apr 2011, 09:10 AM
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 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 20 Apr 2011, 09:21 AM
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.

0
Andrew
Top achievements
Rank 1
answered on 20 Apr 2011, 09:31 AM
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.
Asked by
Andrew
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Andrew
Top achievements
Rank 1
Share this question
or