protected
override
void
SetupFilterControls(TableCell cell)
{
base
.SetupFilterControls(cell);
cell.Controls.RemoveAt(0);
RadComboBox combo =
new
RadComboBox();
combo.ID = (
"RadComboBox1"
+
this
.UniqueName);
combo.ShowToggleImage =
false
;
//combo.Skin = "Office2007";
combo.EnableLoadOnDemand =
true
;
combo.AutoPostBack =
true
;
combo.MarkFirstMatch =
true
;
combo.Height = Unit.Pixel(100);
combo.ItemsRequested +=
this
.list_ItemsRequested;
combo.SelectedIndexChanged +=
this
.list_SelectedIndexChanged;
cell.Controls.AddAt(0, combo);
ImageButton button =
new
ImageButton();
button.ImageUrl =
"~/images/delete.gif"
;
button.Click +=
this
.button_Click;
button.CssClass =
"ClearButton"
;
cell.Controls.AddAt(1, button);
cell.Controls.RemoveAt(2);
}
Hi everyone,
I have an issue regarding column editors. This is the scenario:
I have a radgrid with 3 columns. Two of them are GridDateTimeColumns, the other is a GridNumericColumn.
In edit mode (using“PopUp”) I select both dates. As soon as I select the second date I want to calculate the difference between these two dates and place the result (in years) into the NumericColumn. But I do not want to do this in the server side (SelectedDateChanged event). Instead, I want to perform this functionality in the client side in order to make it more “Dynamic” to the user.
I understand I have to program this within the ItemCreated event and include a javascript function in my aspx.
My problem is that I have not been able to find an attribute that I can add to the second GridDateTimeColumnEditor in order to fire an event as soon as I select the date from the calendar.
This is what I have so far but does not work as I expected: (the Onclick or Onblur events force me to place focus on the dateinput of the second datepicker in order to fire the calculation. I want this to happen as soon as I select the date.)
C#:
protected
void
RgridSigPoros_ItemCreated(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditableItem && (e.Item.IsInEditMode))
{
GridEditableItem item = e.Item
as
GridEditableItem;
GridDateTimeColumnEditor editorFechaFuga = (GridDateTimeColumnEditor)item.EditManager.GetColumnEditor(
"FechaFuga"
);
GridDateTimeColumnEditor editorFechaFabrica = (GridDateTimeColumnEditor)item.EditManager.GetColumnEditor(
"FechaFabrica"
);
GridNumericColumnEditor editorTiempoUso = (GridNumericColumnEditor)item.EditManager.GetColumnEditor(
"TiempoUso"
);
editorFechaFabrica.PickerControl..Attributes.Add(
"onfocus"
,
"return CalculateDiffDate('"
+ editorFechaFuga.PickerControl.ClientID +
"','"
+ editorFechaFabrica.PickerControl.ClientID +
"','"
+ editorTiempoUso.NumericTextBox.ClientID +
"')"
);
editorTiempoUso.NumericTextBox.Enabled =
false
;
}
}
function
CalculateDiffDate(DPoroID, DFabricaID, CTotalID)
{
var
DatePoro = $find(DPoroID).get_selectedDate();
var
DateFabrica = $find(DFabricaID).get_selectedDate();
var
TiempoUso = $find(CTotalID);
//Set 1 day in milliseconds
var
one_day=1000 * 60 * 60 * 24 ;
//Calculate difference btw the two dates, and convert to years
var
total = Math.ceil((DatePoro.getTime()-DateFabrica.getTime())/(one_day))/365;
TiempoUso.set_value(total);
}
<table style="vertical-align: top;"> <tr> <td style="vertical-align: top;"> <label> <asp:Literal ID="Literal1" runat="server" meta:resourceKey="RadPanelLeftLabel" /> </label> <br /> <telerik:RadListBox runat="server" ID="RadListBoxSource" Height="200px" Width="200px" AllowTransfer="true" TransferToID="RadListBoxDestination" TransferMode="Copy" AllowReorder="false" SelectionMode="Multiple" EnableDragAndDrop="true" ButtonSettings-TransferButtons="TransferFrom,TransferAllFrom" OnClientTransferred="ShowHideValidationMessage" AutoPostBackOnTransfer="true" OnTransferred="SortDestinationListBox" /> </td> <td style="vertical-align: top;"> <label> <asp:Literal ID="Literal2" runat="server" meta:resourceKey="RadPanelRightLabel" /> </label> <br /> <telerik:RadListBox runat="server" ID="RadListBoxDestination" Height="200px" Width="200px" AllowReorder="false" AllowDelete="true" /> <asp:Label ID="lblRadListBoxDestinationEmpty" runat="server" Font-Bold="true" ForeColor="Red" meta:resourceKey="lblRadListBoxDestinationEmpty" Visible="false"/> </td> </tr> </table>
<
asp:UpdatePanel runat="server" ID="EventUpdatePanel" UpdateMode="Conditional">
<ContentTemplate>
<telerik:RadScheduler ID="EventScheduler" runat="server"
OverflowBehavior="Expand"
width="100%"
Skin="Web20"
ReadOnly="true"
DataKeyField="EventId"
EnableEmbeddedSkins="false"
DataSubjectField="Subject"
DataStartField="StartTime"
DataEndField="EndTime"
DataDescriptionField="Description"
TimelineView-UserSelectable="false"
ShowAllDayRow="true"
ShowFullTime="false"
FirstDayOfWeek="Monday"
LastDayOfWeek="Friday"
SelectedView="MonthView"
MonthView-VisibleAppointmentsPerDay="4"
RowHeight="30px"
OnAppointmentCommand="EventScheduler_AppointmentCommand">
<AppointmentTemplate>
<div>
<%
#Eval("Subject") %>
<br />
</div>
</AppointmentTemplate>
</telerik:RadScheduler>
<telerik:RadToolTipManager runat="server" ID="EventToolTipManager"
Width="320" Height="210"
Animation="Fade"
HideEvent="LeaveToolTip"
Text="Loading..."
RelativeTo="Element"
Position="TopLeft"
OnClientBeforeShow="clientBeforeShow"
EnableShadow="true"
OnAjaxUpdate="EventToolTipManager_AjaxUpdate" />
</ContentTemplate>
</
asp:UpdatePanel>