I have a grid with a combo box in a template column and a date-time column all rows in the grid are in edit mode so in order to display additional info i need to add an on-focus event to trigger the additional data display.
but it fails to trigger the event !! in on click it works fine ?
here is my code :
C#
protected void RadGridTaskAssinging_ItemDataBound(object sender, GridItemEventArgs e)
{
for (int i = 0; i < RadGridTaskAssinging.PageSize; i++)
{
RadGridTaskAssinging.EditIndexes.Add(i);
}
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem edititem = (GridEditableItem)e.Item;
RadDatePicker dPicker = (RadDatePicker)edititem["New_REMINDER_DATE_TIME"].Controls[0];
dPicker.Width = Unit.Pixel(150);
dPicker.Attributes.Add("onfocus", "ClickMe(" + edititem.GetDataKeyValue("S_ORDER_NUM") + "," + edititem.GetDataKeyValue("ACTIVE_NO") + ");");
RadComboBox RadComboBoxUser = edititem.FindControl("RadComboBoxUser") as RadComboBox;
RadComboBoxUser.Attributes.Add("onfocus", "ClickMe(" + edititem.GetDataKeyValue("S_ORDER_NUM") + "," + edititem.GetDataKeyValue("ACTIVE_NO") + ");");
}
}
ASPX CODE
<telerik:GridDateTimeColumn DataType="System.DateTime"
DataField="New_REMINDER_DATE_TIME"
HeaderText="Internal End Date"
CurrentFilterFunction="EqualTo"
AutoPostBackOnFilter="true"
SortExpression="New_REMINDER_DATE_TIME"
UniqueName="New_REMINDER_DATE_TIME"
FilterControlWidth="150px"
ReadOnly="False"
PickerType="DateTimePicker">
<ItemStyle Wrap="False"/>
<HeaderStyle Width="190px" />
</telerik:GridDateTimeColumn>
<telerik:GridTemplateColumn DataField="T_User.USER_NAME"
HeaderText="Employee"
GroupByExpression="T_User.USER_NAME"
SortExpression="T_User.USER_NAME"
UniqueName="USER_NAME"
FilterControlWidth="80px">
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "T_User.USER_NAME")%>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox ID="RadComboBoxUser"
runat="server"
ShowDropDownOnTextboxClick="false"
MarkFirstMatch="true"
AppendDataBoundItems="True"
Width="110px"
DataSourceID="LinqDataSourceUser"
DataTextField="USER_NAME"
DataValueField="USER_CODE"
SelectedValue='<%# Bind("USER_CODE")%>'>
</telerik:RadComboBox>
<script type="text/javascript">
function ClickMe(Order, Active) {
var inputOrder = document.getElementById("<%= input_S_ORDER_NUM.ClientID%>");
var inputActive = document.getElementById("<%= input_ACTIVE_NO.ClientID%>");
inputOrder.value = Order;
inputActive.value = Active;
var button = document.getElementById("<%= ButtonUpdateDetailes.ClientID%>");
button.disabled = false;
button.focus();
button.click();
}
</script>
</EditItemTemplate>
<ItemStyle Wrap="False" />
<HeaderStyle Width="120px" />
</telerik:GridTemplateColumn>
<asp:ImageButton ID="ButtonUpdateDetalies" runat="server" Enabled="false"
ImageUrl="~/Images/Empty.png" Visible="true" />
I found this post but it doesnt enable me to send parameters to the Javascript !!
but it fails to trigger the event !! in on click it works fine ?
here is my code :
C#
protected void RadGridTaskAssinging_ItemDataBound(object sender, GridItemEventArgs e)
{
for (int i = 0; i < RadGridTaskAssinging.PageSize; i++)
{
RadGridTaskAssinging.EditIndexes.Add(i);
}
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem edititem = (GridEditableItem)e.Item;
RadDatePicker dPicker = (RadDatePicker)edititem["New_REMINDER_DATE_TIME"].Controls[0];
dPicker.Width = Unit.Pixel(150);
dPicker.Attributes.Add("onfocus", "ClickMe(" + edititem.GetDataKeyValue("S_ORDER_NUM") + "," + edititem.GetDataKeyValue("ACTIVE_NO") + ");");
RadComboBox RadComboBoxUser = edititem.FindControl("RadComboBoxUser") as RadComboBox;
RadComboBoxUser.Attributes.Add("onfocus", "ClickMe(" + edititem.GetDataKeyValue("S_ORDER_NUM") + "," + edititem.GetDataKeyValue("ACTIVE_NO") + ");");
}
}
ASPX CODE
<telerik:GridDateTimeColumn DataType="System.DateTime"
DataField="New_REMINDER_DATE_TIME"
HeaderText="Internal End Date"
CurrentFilterFunction="EqualTo"
AutoPostBackOnFilter="true"
SortExpression="New_REMINDER_DATE_TIME"
UniqueName="New_REMINDER_DATE_TIME"
FilterControlWidth="150px"
ReadOnly="False"
PickerType="DateTimePicker">
<ItemStyle Wrap="False"/>
<HeaderStyle Width="190px" />
</telerik:GridDateTimeColumn>
<telerik:GridTemplateColumn DataField="T_User.USER_NAME"
HeaderText="Employee"
GroupByExpression="T_User.USER_NAME"
SortExpression="T_User.USER_NAME"
UniqueName="USER_NAME"
FilterControlWidth="80px">
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "T_User.USER_NAME")%>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox ID="RadComboBoxUser"
runat="server"
ShowDropDownOnTextboxClick="false"
MarkFirstMatch="true"
AppendDataBoundItems="True"
Width="110px"
DataSourceID="LinqDataSourceUser"
DataTextField="USER_NAME"
DataValueField="USER_CODE"
SelectedValue='<%# Bind("USER_CODE")%>'>
</telerik:RadComboBox>
<script type="text/javascript">
function ClickMe(Order, Active) {
var inputOrder = document.getElementById("<%= input_S_ORDER_NUM.ClientID%>");
var inputActive = document.getElementById("<%= input_ACTIVE_NO.ClientID%>");
inputOrder.value = Order;
inputActive.value = Active;
var button = document.getElementById("<%= ButtonUpdateDetailes.ClientID%>");
button.disabled = false;
button.focus();
button.click();
}
</script>
</EditItemTemplate>
<ItemStyle Wrap="False" />
<HeaderStyle Width="120px" />
</telerik:GridTemplateColumn>
<asp:ImageButton ID="ButtonUpdateDetalies" runat="server" Enabled="false"
ImageUrl="~/Images/Empty.png" Visible="true" />
I found this post but it doesnt enable me to send parameters to the Javascript !!