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

Manipulating RadGrid data inside AdvancedEditTemplate

5 Answers 136 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
pedro pelicano
Top achievements
Rank 1
pedro pelicano asked on 10 May 2010, 04:19 PM
Hello,

A brief explanation of what I want to do:
I'm using a Custom AdvanceEditTemplate to update employee absences. For this I need a RadGrid inside the advanceform to show absence details. Until now no problems. I'm able to populate the grid with data through a SQLDataSource. This grid records must be editable and there is where the problems start as I can't figure how to access the RadGrid (RadGrid3) update line that is nested in the AdvancedEditTemplate. In this radgrid I must have a UploadFile control to save an attachment (to filesystem) and a textbox to update a "Reason" property. I need to update this record in the absence table through an SQLDataSource which will call an SP to update these two collumns (attachment link and reason). For this I'm using the Grids UpdateCommand
event as shown below:


CodeBehind:
protected void RadGrid3_UpdateCommand(object sender, GridCommandEventArgs e)
        {
            //Insert Record in Portal Absence Tables for a Update Action
            //Properties: Reason, Attachment, Action(UPDATE),Status(1)
            GridEditableItem editedItem = e.Item as GridEditableItem;
            

            Session["lResourceAbsenceDetailID"] = editedItem["lResourceAbsenceDetailID"].Text;
            Session["Reason"] = "";
            Session["Status"] = 1;
            Session["Action"] = "UPDATE";
            Session["Attachment"] = attachment;
            SqlDataSource5.Select(DataSourceSelectArguments.Empty);
        }




ASPNET COde:
    <telerik:RadScheduler ID="RadScheduler1" OnClientAppointmentDoubleClick="OnClientAppointmentDoubleClick"
        runat="server" SelectedView="MonthView" TimelineView-UserSelectable="false" WeekView-UserSelectable="true"
        GroupingDirection="Vertical" OverflowBehavior="Expand" Skin="Outlook" DataSourceID="SqlDataSource1"
        TimelineView-HeaderDateFormat="mm-yy" StartInsertingInAdvancedForm="True" TimelineView-ColumnHeaderDateFormat="dd"
        OnAppointmentClick="RadScheduler1_AppointmentClick" OnAppointmentDataBound="RadScheduler1_AppointmentDataBound"
        OnFormCreating="RadScheduler1_FormCreating" OnFormCreated="RadScheduler1_FormCreated"
        OnAppointmentCommand="RadScheduler1_AppointmentCommand" DataEndField="EndDate"
        DataKeyField="lResourceAbsenceID" DataStartField="StartDate" DataSubjectField="Name"
        MonthView-AdaptiveRowHeight="true" OnClientAppointmentDeleting="OnClientAppointmentDeleting">
        <Localization ConfirmDeleteText="Tem a certeza que pretende eliminar esta ausência?"
            ConfirmDeleteTitle="Confirmar Eliminação" />
        <AdvancedForm Modal="true" />
        <MonthView AdaptiveRowHeight="True" />
        <AdvancedEditTemplate>
            <div class="rsAdvancedEdit" style="position: relative">
                <%-- Title bar. --%>
                <div class="rsAdvTitle">
                    <%-- The rsAdvInnerTitle element is used as a drag handle when the form is modal. --%>
                    <h1 class="rsAdvInnerTitle">
                    </h1>
                    <asp:LinkButton ID="AdvancedEditCloseButton" runat="server" CausesValidation="false"
                        CommandName="Cancel" CssClass="rsAdvEditClose" ToolTip="close"> close
                    </asp:LinkButton>
                </div>
                <div class="rsAdvContentWrapper">
                    <telerik:RadGrid ID="RadGrid3" runat="server" AutoGenerateEditColumn="True" DataSourceID="SqlDataSource9"
                        GridLines="None" OnUpdateCommand="RadGrid3_UpdateCommand" Skin="Outlook" ClientSettings-Selecting-AllowRowSelect="true">
                        <MasterTableView AutoGenerateColumns="False" DataSourceID="SqlDataSource9">
                            <RowIndicatorColumn>
                                <HeaderStyle Width="20px" />
                            </RowIndicatorColumn>
                            <ExpandCollapseColumn>
                                <HeaderStyle Width="20px" />
                            </ExpandCollapseColumn>
                            <Columns>
                                <telerik:GridBoundColumn DataField="AbsenceID" DataType="System.Int32" HeaderText="AbsenceID"
                                    ReadOnly="True" SortExpression="AbsenceID" UniqueName="AbsenceID" Visible="false">
                                </telerik:GridBoundColumn>
                                <telerik:GridDropDownColumn DataField="AbsenceCodeID" DataSourceID="SqlDataSource8"
                                    HeaderText="Tipo Ausencia" ListTextField="Name" ListValueField="AbsenceID" ReadOnly="True"
                                    SortExpression="AbsenceCodeID" UniqueName="AbsenceCodeID">
                                </telerik:GridDropDownColumn>
                                <telerik:GridBoundColumn DataField="lResourceAbsenceDetailID" DataType="System.Int32"
                                    HeaderText="lResourceAbsenceDetailID" ReadOnly="True" SortExpression="lResourceAbsenceDetailID"
                                    UniqueName="lResourceAbsenceDetailID" Visible="false">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="lResourceAbsenceID" DataType="System.Int32" HeaderText="lResourceAbsenceID"
                                    ReadOnly="True" SortExpression="lResourceAbsenceID" UniqueName="lResourceAbsenceID"
                                    Visible="false">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="ResourceID" DataType="System.Int32" HeaderText="ResourceID"
                                    ReadOnly="True" SortExpression="ResourceID" UniqueName="ResourceID" Visible="false">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="Hours" DataType="System.Int64" HeaderText="Hours"
                                    ReadOnly="True" SortExpression="Hours" UniqueName="Hours" Visible="false">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="ScheduleDetailID" DataType="System.Int32" HeaderText="ScheduleDetailID"
                                    ReadOnly="True" SortExpression="ScheduleDetailID" UniqueName="ScheduleDetailID"
                                    Visible="false">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="starttime" DataType="System.TimeSpan" HeaderText="Hora Inicio"
                                    ReadOnly="True" SortExpression="starttime" UniqueName="starttime">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="endtime" DataType="System.TimeSpan" HeaderText="Hora Fim"
                                    ReadOnly="True" SortExpression="endtime" UniqueName="endtime">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="Date" DataType="System.DateTime" HeaderText="Data"
                                    ReadOnly="True" SortExpression="Date" UniqueName="Date">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="Reason" HeaderText="Motivo" UniqueName="Reason">
                                </telerik:GridBoundColumn>
                                <telerik:GridAttachmentColumn FileNameTextField="Attachment" HeaderText="Anexo" UniqueName="Attachment">
                                </telerik:GridAttachmentColumn>
                                <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" />
                            </Columns>
                        </MasterTableView>
                    </telerik:RadGrid>
                    <br />
                    <div>
                        <asp:ImageButton ID="btn_AllUsers" runat="server" ImageUrl="~/images/delete.gif"
                            CommandName="DeleteAbsence" />
                        <asp:LinkButton ID="lBtn_DeleteAbsence" Text="Eliminar Tudo" CssClass="SubHead" runat="server"
                            CommandName="DeleteAbsence_" />
                        <br />
                        <asp:Label ID="pl_DeleteRequestMessage" CssClass="SuccessMessage" runat="server"
                            Visible="false" />
                    </div>
                    <asp:Panel ID="ButtonsPanel" runat="server" CssClass="rsAdvancedSubmitArea">
                        <div class="rsAdvButtonWrapper">
                            <%--<asp:LinkButton ID="UpdateButton" runat="server" CommandName="Update" CssClass="rsAdvEditSave"> <span>Salvar</span>
                            </asp:LinkButton>--%>
                            <asp:LinkButton ID="CancelButton" runat="server" CausesValidation="false" CommandName="Cancel"
                                CssClass="rsAdvEditCancel"> <span>VOLTAR</span>
                            </asp:LinkButton>
                        </div>
                    </asp:Panel>
                </div>
            </div>
        </AdvancedEditTemplate>


....but it's not working as I can't get the Grid row that I'm updating through (editedItem["lResourceAbsenceDetailID"].Text;). Another problem is that I'm not able to debug this. Can someone please tell me what I must do to make this work. I would very much apreciate any help.

Cheers,
Pedro



5 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 13 May 2010, 01:55 PM
Hi Pedro,

It might be easier to use the Advanced Templates demo for this case. Also, this code library project might be helpful - Upload in RadScheduler.


All the best,
Peter
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.
0
pedro pelicano
Top achievements
Rank 1
answered on 17 May 2010, 01:41 PM
Hi Peter,

First of all thank you for your help.

I would have no problem using the advanced templates, but  how can I have  a RadGrid inside an advance template?

Cheers,
Pedro
0
Peter
Telerik team
answered on 17 May 2010, 03:27 PM
Hello pedro,

Have you seen this step-by-step tutorial on how to customize the advanced form? Also, you can review the kb articles on how to integrate with the advanced form:

RadEditor
http://www.telerik.com/support/kb/aspnet-ajax/scheduler/integrating-radeditor-in-the-advanced-form-of-radscheduler.aspx

RadComboBox
http://www.telerik.com/support/kb/aspnet-ajax/scheduler/implement-related-radcombobox-controls-in-the-advanced-form.aspx

You will notice that the approach is essentially the same.


Kind regards,
Peter
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.
0
pedro pelicano
Top achievements
Rank 1
answered on 15 Jun 2010, 01:15 AM
Hello,

I finally decided to buy your components all of them. They really are that good I guess. I just have been strugling about this problem.

I followed your advice and I managed to create a user control for the EditAdvanceForm and InsertAdvanceForm (notice that my solution is built on top of DotNetNuke). It works almost fine. The Scheduler opens the EditAdvanceForm and displays what I want the grid a and some other controls where in between is  RadFileUpload.

My objective is to update two collumns of that grid a normal text collumn (reason) and a file attachment collumn (Attachment). At first I tried to do this through the edit/inset form of the RadGrid. Then I tried to put the RadFileUpload outside the grid. But none of the aproaches works. I then found out that RadFileUpload or FileUpload controls cannot be ajaxified and I saw an example. But this example is very complex (121128_uploadscheduler) so that I would need to create arround 10 user controls just to implement this little feature. Is there a simpler way of solving my problem even if I need to cheat to achieve my goal. I'll attach my two projects The one that contains the Scheduler and the one that contains AdvanceEditForm. It seems like a waste to have 2 project but since we're talking DNN here it has been the only way I was able to make it work. I really apreciate your help and ask you to solve my problem as fast as you can since I need to have this implemented until tomorrow by the end of the day.

Here are the files link: http://rapidshare.com/files/399104827/DNN_AbsenceManagementModules.rar.html

The impotant user controls are the ones that star with View... There are a lot more user controls since DNN is built to work with tipically 3 usercontrols per module (view, edit and settings).

Thank you,
Pedro
0
Peter
Telerik team
answered on 17 Jun 2010, 11:51 AM
Hi pedro,

We noticed that you wrap RadScheduler in RadAjaxPanel. In this case, we recommend you use RadAsyncUpload instead of RadUpload. With RadAsyncUpload, you will not need to make a real postback to upload files. Please, try this and let us know how it goes.


Best wishes,
Peter
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
Scheduler
Asked by
pedro pelicano
Top achievements
Rank 1
Answers by
Peter
Telerik team
pedro pelicano
Top achievements
Rank 1
Share this question
or