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

Grouping not working in Client

3 Answers 293 Views
Grid
This is a migrated thread and some comments may be shown as answers.
VEDA VIDVA NARAYANAN SATTANATHAN
Top achievements
Rank 1
VEDA VIDVA NARAYANAN SATTANATHAN asked on 02 Jan 2009, 07:04 AM
Hi
I am using telerik grid and data is bound programatically to the grid.
When i allow grouping in the client side and drag and drop columns to group it throws the error shown beolw (even after setting the groupby expressions for the columns).Please find the code to populate grid and the apsx content at the end of the mail.

Expression cannot be null or empty

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Telerik.Web.UI.GridGroupByException: Expression cannot be null or empty

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[GridGroupByException: Expression cannot be null or empty]
   Telerik.Web.UI.GridGroupByExpression.SetExpression(String expression) +99
   Telerik.Web.UI.GridGroupByExpression.set_Expression(String value) +29
   Telerik.Web.UI.GridGroupByExpression..ctor(GridColumn column) +305
   Telerik.Web.UI.RadGrid.RaisePostBackEvent(String eventArgument) +6231
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +177
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746


Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433


ASPX Content of grid:

 

<telerik:RadGrid ID="RadGrid1" runat="server"

 

 

    AllowCustomPaging="True"

 

 

    AutoGenerateColumns="False"

 

 

    AllowPaging="True"

 

 

    AllowFilteringByColumn="True"

 

 

    AllowSorting="True"

 

 

    GridLines="None"

 

 

    ShowGroupPanel="True" 
    GroupingEnabled="True"

 

 

    ongridexporting="RadGrid1_GridExporting1"

 

 

    onpdfexporting="RadGrid1_PdfExporting"

 

 

    onpageindexchanged="RadGrid1_PageIndexChanged1"

 

 

    ongroupschanging="RadGrid1_GroupsChanging" onneeddatasource="RadGrid1_NeedDataSource">

 

<

 

MasterTableView>

 

<

 

RowIndicatorColumn>

 

<

 

HeaderStyle Width="20px"></HeaderStyle>

 

</

 

RowIndicatorColumn>

 

</

 

MasterTableView>

 

<

 

ClientSettings AllowDragToGroup="true">
</
ClientSettings>

 

<

 

PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="True" />

 

<

 

FilterMenu EnableTheming="True">

 

<

 

CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>

 

</

 

FilterMenu>

 

 

</telerik:RadGrid>

Code:

public

 

void PopulateGrid()

 

{

 

DataSet ds = new DataSet();
SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM abc", "server=10.100.111.11;database=abcd;Uid=aa;pwd=aa;");

 

adapter.Fill(ds);


foreach
(DataColumn col in ds.Tables[0].Columns)

 

{

 

    GridBoundColumn gridboundcolumn = new GridBoundColumn();

 

    gridboundcolumn.DataField = col.ColumnName;

    gridboundcolumn.HeaderText = col.ColumnName

;

 

    gridboundcolumn.UniqueName = col.ColumnName;

    gridboundcolumn.SortExpression = col.ColumnName;

    gridboundcolumn.Display =

true;

 

    gridboundcolumn.Groupable =

true;

 

    gridboundcolumn.GroupByExpression = gridboundcolumn.GetDefaultGroupByExpression();

    RadGrid1.Columns.Add(gridboundcolumn);

}

RadGrid1.VirtualItemCount = 2000;

 

RadGrid1.DataBind();

 

}

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 02 Jan 2009, 09:33 AM
Hello Sattanathan,

How are you binding the grid? I hope you are using SimpleDataBinding i.e., calling DataBind() to bind the grid. Try using AdvancedDataBinding techniques instead to bind the grid, as features like Grouping, Sorting etc. are supported only with AdvancedDataBinding. For more information on AdvancedDataBinding, you can refer to the following online demo link:
Advanced data-binding

Thanks
Princy.
0
VEDA VIDVA NARAYANAN SATTANATHAN
Top achievements
Rank 1
answered on 02 Jan 2009, 01:26 PM
Hi Princy,

Thanks for the reply but i am using only needdatasource event to populate the grid still i get the same error.
Please see the code file below.

public
 partial class _Default : System.Web.UI.Page   
{  
    protected void Page_Load(object sender, EventArgs e)  
    {  
 
    }  
 
    protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)  
    {  
        DataSet ds = new DataSet();  
        int pageIndex = RadGrid1.CurrentPageIndex + 1;  
        int rowEnd = (pageIndex * 10);  
        int rowStart = (pageIndex * 10) - 9;  
        SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM (SELECT ROW_NUMBER() OVER (ORDER BY CallNumber) AS ROWID, callnumber,sltunique1,callprioritycode FROM Call) as temptable where ROWID BETWEEN " + rowStart.ToString() + " AND " + rowEnd.ToString(), "server=10.100.111.11;database=aa;Uid=sa;pwd=a;");  
        adapter.Fill(ds);  
        RadGrid1.DataSource = ds.Tables[0]; ;  
 
        //RadGrid1.AutoGenerateColumns = false;  
 
        foreach (DataColumn col in ds.Tables[0].Columns)  
        {  
            GridBoundColumn gridboundcolumn = new GridBoundColumn();  
            gridboundcolumn.DataField = col.ColumnName;  
            gridboundcolumn.HeaderText = col.ColumnName;  
            gridboundcolumn.UniqueName = col.ColumnName;  
            gridboundcolumn.SortExpression = col.ColumnName;  
            gridboundcolumn.Display = true;  
            gridboundcolumn.GroupByExpression = col.ColumnName + " Group By " + col.ColumnName;  
            gridboundcolumn.Display = true;  
            RadGrid1.Columns.Add(gridboundcolumn);  
        }  
 
        RadGrid1.VirtualItemCount = 2000;  
        //GridGroupByExpression expression1 = GridGroupByExpression.Parse("sltunique1 [SLTUNIQUE1], sum(sltunique1) Items [SLT SUM] Group By sltunique1");  
        //this.RadGrid1.MasterTableView.GroupByExpressions.Add(expression1);  
        //RadGrid1.DataBind();   
        //RadGrid1.VirtualItemCount = 2000;  
        //RadGrid1.DataBind();  
    }  
0
Arnold Smith
Top achievements
Rank 1
answered on 04 Aug 2009, 06:08 PM
Princy,

Has there been any movement regarding the resolution of this error.

My situation is the roughly the same as the questioner.

The condition under which this error occurs: Like a curious user...I'm trying to drag an empty column to group by area. This is just the sort of thing a user would do, absentmindedly. An empty column is created when I drag a 'real' column to the loading area. I'm using Q1 2009.
 

 

<telerik:radajaxloadingpanel ToolTip="Drag column headers here to group"

 

 

ID="RadAjaxLoadingPanel1" runat="server" Transparency="70" Width="100%">

 

 

</telerik:radajaxloadingpanel>

 

 

<telerik:radgrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True"

 

 

AllowPaging="True" AllowSorting="True" AutoGenerateColumns="false"

 

 

GridLines="None" Skin="Office2007" CellPadding="3" Width="100%" OnSelectedIndexChanged="RadGrid1_SelectedIndexChanged"

 

 

OnInit="RadGrid1_Init" OnItemDataBound="RadGrid1_ItemDataBound"

 

 

OnItemCreated="RadGrid1_ItemCreated" OnNeedDataSource="RadGrid1_NeedDataSource"

 

 

PageSize="5" PagerStyle-AlwaysVisible="true" OnPreRender="RadGrid1_PreRender"

 

 

GroupingSettings-CaseSensitive="false" EnableViewState="true"

 

 

ShowGroupPanel="True" ongroupschanging="RadGrid1_GroupsChanging" >

 

 

 

<FilterMenu EnableTheming="True">

 

 

<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>

 

 

</FilterMenu>

 

 

 

<FooterStyle BackColor="Yellow" Width="100%" />

 

 

<PagerStyle AlwaysVisible="True" HorizontalAlign="Left" Width="100%"></PagerStyle>

 

 

<MasterTableView DataKeyNames="leadId"

 

 

NoMasterRecordsText="Currently no records found. Please review your search criteria." AllowMultiColumnSorting="false" >

 

 

<ExpandCollapseColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" Resizable="False" Visible="False"/>

 

 

<RowIndicatorColumn CurrentFilterFunction="NoFilter"

 

 

FilterListOptions="VaryByDataType" Visible="False">

 

 

<HeaderStyle Width="20px"></HeaderStyle>

 

 

</RowIndicatorColumn>

 

 

 

<ExpandCollapseColumn>

 

 

<HeaderStyle Width="20px"></HeaderStyle>

 

 

</ExpandCollapseColumn>

 

 

<Columns>

 

 

<telerik:GridTemplateColumn AllowFiltering="false">

 

 

<ItemStyle HorizontalAlign="Center" />

 

 


<
ItemTemplate>

 

 

<asp:ImageButton PostBackUrl="~/Reports/LeadList.aspx" OnClick="ViewLeadDetails_Click" CommandArgument='<%#Eval("leadId").ToString()%>' ID="ImageButton1" runat="server" CausesValidation="False" CommandName="Select" ImageUrl="~/Images/Magnify.gif" ToolTip="View lead details" />

 

 

</ItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 


<
telerik:GridBoundColumn UniqueName="leadSource" Groupable="true" ReadOnly="true" DataField="leadSource" SortExpression="leadSource" HeaderText="Lead Source" CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" Aggregate="Count" FooterText="Total Lead Source: "></telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn UniqueName="nameConcat" Groupable="true" ReadOnly="true" DataField="nameConcat" SortExpression="nameConcat" HeaderText="Customer Name" AllowFiltering="true" CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"></telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn UniqueName="model" Groupable="true" ReadOnly="true" DataField="model" SortExpression="model" HeaderText="Model" AllowFiltering="true" FilterListOptions="VaryByDataType"></telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn UniqueName="score" Groupable="true" ReadOnly="true" DataField="score" SortExpression="score" HeaderText="Score" AllowFiltering="true" CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"></telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn UniqueName="leadDate" Display="false" Groupable="true" ReadOnly="true" DataField="leadDate" SortExpression="leadDate" HeaderText="Lead Date" CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"></telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn UniqueName="leadAgeInDays" Groupable="true" ReadOnly="true" DataField="leadAgeInDays" SortExpression="leadAgeInDays" HeaderText="Lead Age" CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"></telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn UniqueName="zip" Groupable="true" ReadOnly="true" DataField="zip" SortExpression="zip" HeaderText="Zip" CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"></telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn UniqueName="dealer" Groupable="true" ReadOnly="true" DataField="dealer" SortExpression="dealer" HeaderText="Dealer" AllowFiltering="true" CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"></telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn UniqueName="disposition" Groupable="true" ReadOnly="true" DataField="disposition" SortExpression="disposition" HeaderText="Status" CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"></telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn UniqueName="salesperson" Groupable="true" ReadOnly="true" DataField="salesperson" SortExpression="salesperson" HeaderText="Salesperson" CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"></telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn UniqueName="leadIdLeadList" Display="false" Groupable="true" ReadOnly="true" DataField="leadId" SortExpression="leadId" HeaderText="Lead Id" CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"></telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn UniqueName="duplicateLeadIdLeadList" Display="false" Groupable="false" ReadOnly="true" DataField="duplicateLeadId" SortExpression="duplicateLeadId" HeaderText="Duplicate Lead Id" CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"></telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn UniqueName="duplicateLeadList" Display="false" Groupable="false" ReadOnly="true" DataField="duplicate" SortExpression="duplicate" HeaderText="Is Duplicate" CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"></telerik:GridBoundColumn>

 

 

</Columns>

 

 

 


<
AlternatingItemStyle BackColor="LightYellow" />

 

 


<
HeaderStyle HorizontalAlign="Center"></HeaderStyle>

 

 

</MasterTableView>

 

 

 


<
GroupingSettings CaseSensitive="False" />

 

 

<GroupHeaderItemStyle HorizontalAlign="Left" Height="20px" Width="100%"></GroupHeaderItemStyle>

 

 

<ClientSettings Selecting-AllowRowSelect="true" AllowColumnsReorder="True" ReorderColumnsOnClient="True" AllowDragToGroup="true">

 

 

<Selecting AllowRowSelect="True"></Selecting>

 

 

</ClientSettings>

 

 

<SortingSettings SortedBackColor="Linen" />

 

 

</telerik:radgrid>

Thanks,

Arnold

 

Tags
Grid
Asked by
VEDA VIDVA NARAYANAN SATTANATHAN
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
VEDA VIDVA NARAYANAN SATTANATHAN
Top achievements
Rank 1
Arnold Smith
Top achievements
Rank 1
Share this question
or