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

Grouped Radgrid loads only once

3 Answers 50 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Parimal
Top achievements
Rank 1
Parimal asked on 10 Oct 2012, 01:47 PM

Hi,

I am using radgrid with grouping options,the problem it loads fine ,however after that it never binds even on paging,sorting or on other controls.when i remove grouping  it works fine. can you please reply soon.its very urgent.

below is my code

  <telerik:RadGrid ID="RgrdConsultantVacationweek" AutoGenerateColumns="false" AllowPaging="true"
                    PageSize="8" runat="server" DataMember="ConsultantID" OnNeedDataSource="RgrdConsultantVacationweek_NeedDataSource"
                    AllowSorting="true" OnItemCommand="RgrdConsultantVacationweek_ItemCommand" ShowGroupPanel="true"
                    ShowFooter="True">
                    <ExportSettings HideStructureColumns="true" />
                    <ClientSettings>
                        <Selecting AllowRowSelect="true" />
                        <ClientEvents OnRowDblClick="OnRowDblClick" />
                    </ClientSettings>
                    <MasterTableView CommandItemDisplay="Top" ClientDataKeyNames="VacationRequestID"
                        ShowGroupFooter="true" EnableViewState ="true">
                        <CommandItemTemplate>
                            <table width="100%">
                                <tr>
                                    <td style="text-align: right">
                                        <asp:LinkButton ID="LnkExportToexcel" runat="server" CommandName="ExportToExcel">
                                            <asp:Image ID="imgexportToexcel" ImageUrl="~/Img/Export to excel.gif" runat="server" />
                                        </asp:LinkButton>
                                        &nbsp;
                                        <asp:LinkButton ID="LnkExportTopdf" runat="server" CommandName="ExportTopdf">
                                            <asp:Image ID="ImgPdf" ImageUrl="~/Img/ExportToPDF.gif" runat="server" />
                                        </asp:LinkButton>
                                        &nbsp;
                                        <asp:LinkButton ID="LnkExporrtToCsv" runat="server" CommandName="ExporrtToCsv">
                                            <asp:Image ID="Imgcsv" ImageUrl="~/Img/ExportToCSV.gif" runat="server" />
                                        </asp:LinkButton>
                                        &nbsp;
                                        <asp:LinkButton ID="LnkExportToWord" runat="server" CommandName="ExportToWord">
                                            <asp:Image ID="ImgWord" ImageUrl="~/Img/ExportToWord.gif" runat="server" />
                                        </asp:LinkButton>
                                    </td>
                                </tr>
                            </table>
                        </CommandItemTemplate>
                        <GroupHeaderTemplate>
                            <asp:Label runat="server" ID="Label1" Text='<%#Eval("vacationmonth") %>' Visible="true">
                            </asp:Label>
                        </GroupHeaderTemplate>
                        <GroupFooterTemplate>
                          
                            <asp:Label ID="lblBusinessdaystext" Text="Total  " runat="server"></asp:Label>
                            <asp:Label ID="lblBusinessdays" runat="server" Text='<%# Eval("Businessdays") %>'>
                            </asp:Label>
                        </GroupFooterTemplate>
                        <Columns>
                            <telerik:GridBoundColumn DataField="VacationRequestID" HeaderText="VacationRequestID"
                                Visible="false">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="ConsultantID" HeaderText="ConsultantID" Visible="false">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="ConsultantName" HeaderText="Resource" SortExpression="ConsultantName">
                            </telerik:GridBoundColumn>
                            <telerik:GridTemplateColumn ItemStyle-Width="15%" HeaderText="Dates">
                                <ItemTemplate>
                                    <asp:Label ID="lblDates" runat="server" Text='<%#String.Format("{0}-{1}", Eval("startdate").ToString(),Eval("enddate").ToString()) %>'></asp:Label>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridBoundColumn Aggregate="Sum" DataField="Businessdays" HeaderText="Business Days"
                                Visible="true" FooterText="Total   ">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Approved" HeaderText="Approved" Visible="true">
                            </telerik:GridBoundColumn>
                        </Columns>
                        <GroupByExpressions>
                            <telerik:GridGroupByExpression>
                                <GroupByFields>
                                    <telerik:GridGroupByField FieldName="vacationmonth" />
                                </GroupByFields>
                            </telerik:GridGroupByExpression>
                        </GroupByExpressions>
                    </MasterTableView>
                </telerik:RadGrid>




protected void RgrdConsultantVacationweek_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {
            try
            {
                BindRgrdConsultantVacationweek();
            }
            catch (Exception ex)
            {


            }
        }


        protected void BindRgrdConsultantVacationweek()
        {
            try
            {
                //DateTime lastDate = GetLastDateOfWeek((DateTime.Now).Date, DayOfWeek.Saturday);
                DataTable dt = GetConsultantRequest(Convert.ToInt32(Session["CRUserID"]), true, Convert.ToInt32(Session["UserType"]), Convert.ToInt32(ddlTypeOfLeave.SelectedValue), rdpProjectStartDate.SelectedDate, rdpProjectEndDate.SelectedDate, Convert.ToInt32(ddlPractices.SelectedValue));
                RgrdConsultantVacationweek.DataSource = dt;
               
            }
            catch (Exception ex)
            {


            }
        }
thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 12 Oct 2012, 01:44 PM
Hi Parimal,

I have created a sample RadGrid web site using the provided code snippet. On my side the grouping works as expected. Please check out the attached application and try to distinguish the crucial differences between our projects.

Regards,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Parimal
Top achievements
Rank 1
answered on 12 Oct 2012, 02:02 PM
Thanks for your reply.

actually it was toatally my mistake.i failed to provide select fields in group settings

<SelectFields>
                                    <telerik:GridGroupByField FieldAlias="vacationmonth" FieldName="vacationmonth" />
                                </SelectFields>

However,I still did not understand whats link between above setting and binding of grid.

trhanks again for your reply.
0
Eyup
Telerik team
answered on 12 Oct 2012, 02:12 PM
Hi Parimal,

The SelectFields collection determines the information that is displayed in the group header by getting a collection of SelectField objects (field names, aggregates etc.) that form the "Select" clause.

You could check out the following topic for additional information:
http://www.telerik.com/help/aspnet-ajax/grid-group-by-declarative-definition.html

I hope this will prove helpful.

Greetings,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
General Discussions
Asked by
Parimal
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Parimal
Top achievements
Rank 1
Share this question
or