This is a migrated thread and some comments may be shown as answers.

Inline Editing with radgrid and need to bind javascipt runtim

1 Answer 26 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Amitkumar
Top achievements
Rank 1
Amitkumar asked on 24 Feb 2010, 09:12 AM
Hello All,

I am using RadGrid in UserControl, and that user control call from aspx page,

I am using RadGrid with inline editing to insert, and update records, during editing when i click on save button(i.e. Image) that time it will fire the following event, and based on proxyAttendeeAvailable.IsInvitedOrBookedForAnyAgenda(eventAttendeeId, (System.DateTime)rdpDate.SelectedDate, (System.DateTime)rtpTimeFrom.SelectedDate, (System.DateTime)rtpTimeTo.SelectedDate) function result bind the javascipt function and it should fire the javascript function mention below, what was wrong with javascipt binding, and why javascipt function is not executed.

protected void rgAvailability_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
    if (!e.Item.OwnerTableView.IsItemInserted)
            {
                AttendeeAvailableDateAndTimeService.AttendeeAvailableDateAndTimeClient proxyAttendeeAvailable = new ePlannerPro2Client.AttendeeAvailableDateAndTimeService.AttendeeAvailableDateAndTimeClient();

                try
                {
                    RadDatePicker rdpDate = e.Item.FindControl("txtAvailableDate") as RadDatePicker;
                    RadTimePicker rtpTimeFrom = e.Item.FindControl("txtTimeFrom") as RadTimePicker;
                    RadTimePicker rtpTimeTo = e.Item.FindControl("txtTimeTo") as RadTimePicker;

                    System.DateTime vsDate = System.Convert.ToDateTime(ViewState["AvailabilityDate"].ToString());
                    System.DateTime vsFromTime = System.Convert.ToDateTime(ViewState["AvailabilityTimeFrom"].ToString());
                    System.DateTime vsToTime = System.Convert.ToDateTime(ViewState["AvailabilityTimeTo"].ToString());

                    System.Guid eventAttendeeId = System.Guid.Empty;

                    if (CurrentUser != null && !CurrentUser.EventAttendeeId.Equals(System.Guid.Empty))
                    {
                        eventAttendeeId = CurrentUser.EventAttendeeId;
                    }

                    if (!vsDate.Equals(rdpDate.SelectedDate) || !vsFromTime.Equals(rtpTimeFrom.SelectedDate) || !vsToTime.Equals(rtpTimeTo.SelectedDate) && !System.Convert.ToBoolean(hfResult.Value))
                    {
                        if (proxyAttendeeAvailable.IsInvitedOrBookedForAnyAgenda(eventAttendeeId, (System.DateTime)rdpDate.SelectedDate, (System.DateTime)rtpTimeFrom.SelectedDate, (System.DateTime)rtpTimeTo.SelectedDate))
                        {
                            StringBuilder controls = new StringBuilder();
                            ImageButton updateBtn = e.Item.FindControl("UpdateButton") as ImageButton;

                            if (updateBtn != null)
                            {
                                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                                sb.Append(@"IsInvited('" + updateBtn.UniqueID + "');");
                                RadScriptManager.RegisterStartupScript(updateBtn, this.GetType(), "PopupUpdateMsg", sb.ToString(), false);
                                                               
                            }
                        }
                    }
                    else
                    {
                        hfResult.Value = "true";
                    }

                    bool isValid = false;

                    if (System.Convert.ToBoolean(hfResult.Value))
                    {
                        isValid = SubmitRecord(source, e);
                    }

                    if (isValid == false)
                    {
                        e.Canceled = true;
                    }
                }
                catch { }
                finally
                {
                    if (proxyAttendeeAvailable != null)
                    {
                        proxyAttendeeAvailable.Close();
                        proxyAttendeeAvailable = null;
                    }
                }
            }
}

<telerik:RadCodeBlock ID="RadCode" runat="server">
    <script language="javascript" type="text/javascript">
        function IsInvited(sender) {
            alert('Is Invited');
            document.getElementById("<%=hfResult.ClientID %>").value = false;

            var valid = confirm("One of the existing agenda falls outside the updated availibility date and time, would you like to continue?");
            if (valid) {
                document.getElementById("<%=hfResult.ClientID %>").value = valid;
                __doPostBack(sender, '');
                return true;
            }

            return false;
        }
</script>
</telerik:RadCodeBlock>

Thanks in Advance
Amit






1 Answer, 1 is accepted

Sort by
0
Accepted
Mira
Telerik team
answered on 26 Feb 2010, 12:06 PM
Hello Amit,

Please take a look at the RADAjax Manager does not load JS files in dynamically loaded user control forum topic and the attached to it projects to see various ways for implementing the desired functionality.

I hope you find it useful.

Greetings,
Mira
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Amitkumar
Top achievements
Rank 1
Answers by
Mira
Telerik team
Share this question
or