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

RadGrid Filter throwing error

5 Answers 129 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sarath
Top achievements
Rank 1
Sarath asked on 28 Nov 2013, 02:07 PM
I am using Telerik version 2011. 
I have created RadGrid header by using the below code. Under Each header there are sub headers. Each Sub Header is a Rad Grid Column. Each column having Filter Column. Whenever I click on filter button throwing a error in Visual Studio with popup message "Microsoft JScript runtime error: '_data' is null or not an object"

 GridHeaderItem newSubHeaderItem = new GridHeaderItem(FuelSummaryGrid.MasterTableView, 0, 0);
        newSubHeaderItem.Cells.Add(new GridTableHeaderCell() { Text = " ", BackColor = System.Drawing.Color.FromName("#61AAE6") });
        newSubHeaderItem.Cells.Add(new GridTableHeaderCell() { Text = " ", BackColor = System.Drawing.Color.FromName("#61AAE6") });
       newSubHeaderItem.Cells.Add(new GridTableHeaderCell() { Text = Driving, ColumnSpan = 3, HorizontalAlign = HorizontalAlign.Center });
        newSubHeaderItem.Cells.Add(new GridTableHeaderCell() { Text = Shift, ColumnSpan = 3, HorizontalAlign = HorizontalAlign.Center });
        newSubHeaderItem.Cells.Add(new GridTableHeaderCell() { Text = Day, ColumnSpan = 3, HorizontalAlign = HorizontalAlign.Center });
        newSubHeaderItem.Cells.Add(new GridTableHeaderCell() { Text = Week, ColumnSpan = 3, HorizontalAlign = HorizontalAlign.Center });
head.Controls.AddAt(0, newSubHeaderItem);

For the reference please find the images. 

Please help me how to resolve this issue.

5 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 03 Dec 2013, 11:43 AM
Hi Sarath,

Could I kindly ask you to elaborate a bit more on your scenario? Which RadGrid event is used for adding the mentioned header items? How the RadGrid is bind and also is it programmatically created? It will be best if you could open a regular support ticket and send us sample runnable application which demonstrates the mentioned issue.
Thus we will be able to debug it locally and advise you further.

Regards,
Maria Ilieva
Telerik
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 the blog feed now.
0
Sarath
Top achievements
Rank 1
answered on 03 Dec 2013, 12:36 PM
Hi Maria,

Thanks for Your Response!!!!

  We are created the Rad Grid Header through Programmatically by using  RadGrid_PreRender Event. We are not creating the RadGrid Programmatically and binding the RadGrid data by using the DataBind Method only. Please have a look on RadGrid design page what we are created.

<telerik:RadGrid 
                                        ID="Grid" 
                                        runat="server" 
                                        ShowFooter              ="true" 
                                        GridLines               ="Vertical"
                                        ItemStyle-VerticalAlign ="Middle"
                                        ShowHeader              ="true" 
                                        AllowMultiRowSelection  ="false" 
                                        AllowSorting            ="true" 
                                        AllowFilteringByColumn  ="true"                                                                       
                                        PageSize                ="15" 
                                        EnableViewState         ="true"
                                        Height                  ="430px" 
                                        Width                   ="1200px"
                                        ShowStatusBar           ="true" 
                                        EnableLinqExpressions   ="false" 
                                        OnNeedDataSource="FuelSummaryGrid_NeedDataSource" 
                                        OnItemCommand="FuelSummaryGrid_ItemCommand" 
                                        OnItemCreated="FuelSummaryGrid_ItemCreated" 
                                        OnItemDataBound="FuelSummaryGrid_ItemDataBound"
                                        OnSortCommand="FuelSummaryGrid_SortCommand" 
                                        OnPreRender="FuelSummaryGrid_PreRender">
                               <ClientSettings 
                                            EnableRowHoverStyle             ="true" 
                                            ReorderColumnsOnClient          ="false" 
                                            Resizing-AllowColumnResize      ="false"
                                            Resizing-ClipCellContentOnResize="false" 
                                            Resizing-EnableRealTimeResize   ="false">
                                            <Selecting AllowRowSelect="true" />

                               </ClientSettings>
                               <MasterTableView  TableLayout="Auto" AutoGenerateColumns="false"   HeaderStyle-Height="40px"  AllowFilteringByColumn="true" EnableHeaderContextMenu="true" DataKeyNames="Period,DateOrVRN,TotalMatched,TotalUnMatched,TotalOverfill" AllowSorting="true">
                               <Columns> 
                                        <telerik:GridBoundColumn 
                                            HeaderText="Harsh Accelaration" 
                                            AllowSorting="true" 
                                            AllowFiltering="true"
                                            ShowFilterIcon="true" 
                                            ItemStyle-Width="79px"                                           
                                            FilterControlWidth="40px" 
                                            Aggregate="None"
                                            DataField="CardMatchedLitres" 
                                            AutoPostBackOnFilter="true" 
                                            UniqueName="CardMatched" 
                                            DataType="System.Double" 
                                            DataFormatString="{0:###,##0}"
                                            ItemStyle-HorizontalAlign="Center" 
                                            FooterStyle-HorizontalAlign="Center" 
                                            ItemStyle-Font-Size="1.0em"
                                            ItemStyle-Font-Bold="true" 
                                            FooterStyle-Font-Bold="true" 
                                            HeaderStyle-HorizontalAlign="Center">
                                            <ItemStyle CssClass="smallGridText"></ItemStyle>                                                                                                                                                                           
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn 
                                            HeaderText="Harsh Braking" 
                                            AllowSorting="true" 
                                            AllowFiltering="true"
                                            ShowFilterIcon="true" 
                                            ItemStyle-Width="79px"                                             
                                            FilterControlWidth="40px" 
                                            Aggregate="None"
                                            DataField="CardOverfillLitres" 
                                            AutoPostBackOnFilter="true" 
                                            UniqueName="CardOverfill" 
                                            DataType="System.Double" 
                                            DataFormatString="{0:###,##0}"
                                            ItemStyle-HorizontalAlign="Center" 
                                            FooterStyle-HorizontalAlign="Right" 
                                            ItemStyle-Font-Size="1.0em"
                                            ItemStyle-Font-Bold="true" 
                                            FooterStyle-Font-Bold="true" 
                                            HeaderStyle-HorizontalAlign="Center">
                                            <ItemStyle CssClass="smallGridText"></ItemStyle>                                            
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn 
                                            HeaderText="Speeding" 
                                            AllowSorting="true" 
                                            AllowFiltering="true"
                                            ShowFilterIcon="true" 
                                            ItemStyle-Width="79px"                                              
                                            FilterControlWidth="40px" 
                                            Aggregate="None"
                                            DataField="CardUnMatchedLitres" 
                                            AutoPostBackOnFilter="true" 
                                            UniqueName="CardUnMatched" 
                                            DataType="System.Double" 
                                            DataFormatString="{0:###,##0}"
                                            ItemStyle-HorizontalAlign="Center" 
                                            FooterStyle-HorizontalAlign="Center" 
                                            ItemStyle-Font-Size="1.0em"
                                            ItemStyle-Font-Bold="true" 
                                            FooterStyle-Font-Bold="true" 
                                            HeaderStyle-HorizontalAlign="Center">
                                            <ItemStyle CssClass="smallGridText"></ItemStyle>                                           
                                       </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn 
                                            HeaderText="Driving without Breaks" 
                                            AllowSorting="true" 
                                            AllowFiltering="true"
                                            ShowFilterIcon="true" 
                                            ItemStyle-Width="79px"                                            
                                            FilterControlWidth="40px" 
                                            Aggregate="None"
                                            DataField="Purchased" 
                                            AutoPostBackOnFilter="true" 
                                            UniqueName="Purchased" 
                                            DataType="System.Double" 
                                            DataFormatString="{0:###,##0}"
                                            ItemStyle-HorizontalAlign="Center" 
                                            FooterStyle-HorizontalAlign="Center" 
                                            ItemStyle-Font-Size="1.0em"
                                            ItemStyle-Font-Bold="true" 
                                            FooterStyle-Font-Bold="true" 
                                            HeaderStyle-HorizontalAlign="Center">
                                            <ItemStyle CssClass="smallGridText"></ItemStyle>                                            
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn
HeaderText="Insufficient Break Duration"
                                            AllowSorting="true" 
                                            AllowFiltering="true"
                                            ShowFilterIcon="true" 
                                            ItemStyle-Width="79px"                                            
                                            FilterControlWidth="40px" 
                                            Aggregate="None"
                                            DataField="DateOrVRN" 
                                            AutoPostBackOnFilter="true" 
                                            UniqueName="DateOrVRN" 
                                            DataType="System.Int32" 
                                            ItemStyle-HorizontalAlign="Center" 
                                            FooterStyle-HorizontalAlign="Center" 
                                            ItemStyle-Font-Size="1.0em"
                                            ItemStyle-Font-Bold="true" 
                                            FooterStyle-Font-Bold="true" 
                                            HeaderStyle-HorizontalAlign="Center">
                                            <ItemStyle CssClass="smallGridText"></ItemStyle>                                            
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn 
                                            HeaderText="Exceeded Shift Duration" 
                                            AllowSorting="true" 
                                            AllowFiltering="true"
                                            ShowFilterIcon="true" 
                                            ItemStyle-Width="79px"                                            
                                            FilterControlWidth="40px" 
                                            Aggregate="None"
                                            DataField="Vehicle_Name" 
                                            AutoPostBackOnFilter="true" 
                                            UniqueName="Vehicle_Name" 
                                            DataType="System.String" 
                                            ItemStyle-HorizontalAlign="Center" 
                                            FooterStyle-HorizontalAlign="Center" 
                                            ItemStyle-Font-Size="1.0em"
                                            ItemStyle-Font-Bold="true" 
                                            FooterStyle-Font-Bold="true" 
                                            Visible="true"
                                            HeaderStyle-HorizontalAlign="Center">
                                            <ItemStyle CssClass="smallGridText"></ItemStyle>                                            
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn 
                                            HeaderText="Exceeded Driving Duration"
                                            AllowSorting="true" 
                                            AllowFiltering="true"
                                            ShowFilterIcon="true" 
                                            ItemStyle-Width="79px"                                              
                                            FilterControlWidth="40px" 
                                            Aggregate="None"
                                            DataField="Refuelled" 
                                            AutoPostBackOnFilter="true" 
                                            UniqueName="Refuelled" 
                                            DataType="System.Double"
                                            DataFormatString="{0:###,##0}" 
                                            ItemStyle-HorizontalAlign="Center" 
                                            FooterStyle-HorizontalAlign="Right" 
                                            ItemStyle-Font-Size="1.0em"
                                            ItemStyle-Font-Bold="true" 
                                            FooterStyle-Font-Bold="true" 
                                            HeaderStyle-HorizontalAlign="Center">
                                            <ItemStyle CssClass="smallGridText"></ItemStyle>                                           
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn 
                                            HeaderText="Exceeded working Days"
                                            AllowSorting="true" 
                                            AllowFiltering="true"
                                            ShowFilterIcon="true" 
                                            ItemStyle-Width="79px"                                           
                                            FilterControlWidth="40px" 
                                            Aggregate="None"
                                            DataField="VehicleMatchedLitres" 
                                            AutoPostBackOnFilter="true" 
                                            UniqueName="VehicleMatched" 
                                            DataType="System.Double" 
                                            DataFormatString="{0:###,##0}"
                                            ItemStyle-HorizontalAlign="Center" 
                                            FooterStyle-HorizontalAlign="Center" 
                                            ItemStyle-Font-Size="1.0em"
                                            ItemStyle-Font-Bold="true" 
                                            FooterStyle-Font-Bold="true" 
                                            HeaderStyle-HorizontalAlign="Center">
                                            <ItemStyle CssClass="smallGridText"></ItemStyle>                                            
                                         </telerik:GridBoundColumn> 
<telerik:GridBoundColumn 
                                            HeaderText="Insufficient Break Duration"
                                            AllowSorting="true" 
                                            AllowFiltering="true"
                                            ShowFilterIcon="true" 
                                            ItemStyle-Width="79px"                                           
                                            FilterControlWidth="40px" 
                                            Aggregate="None"
                                            DataField="VehicleMatchedLitres" 
                                            AutoPostBackOnFilter="true" 
                                            UniqueName="VehicleMatched" 
                                            DataType="System.Double" 
                                            DataFormatString="{0:###,##0}"
                                            ItemStyle-HorizontalAlign="Center" 
                                            FooterStyle-HorizontalAlign="Center" 
                                            ItemStyle-Font-Size="1.0em"
                                            ItemStyle-Font-Bold="true" 
                                            FooterStyle-Font-Bold="true" 
                                            HeaderStyle-HorizontalAlign="Center">
                                            <ItemStyle CssClass="smallGridText"></ItemStyle>                                            
                                         </telerik:GridBoundColumn> 

                                </Columns>
                              </MasterTableView>
                              <ClientSettings>
                                    
                                    <Scrolling 
                                        AllowScroll="true" 
                                        UseStaticHeaders="True"
                                        SaveScrollPosition="True" 
                                        FrozenColumnsCount="2"
                                        ScrollHeight="400px" 
                                        EnableVirtualScrollPaging="false" />
                            
                            </ClientSettings>
                              </telerik:RadGrid>
Please help me, how to fix this issue......
0
Maria Ilieva
Telerik team
answered on 05 Dec 2013, 03:45 PM
Hi Sarath,

I tried to replicate the described issue locally, using your approach for creating Header Item programmatically and was not bale to replicate the mentioned error on filtering. see my test movie below which presents the correct functionality of this scenario:

http://screencast.com/t/91dm7NlH

In such case it will be best if you could open a regular support ticket and send us sample runnable application which demonstrates the mentioned issue. Thus we will be able to replicate it locally and advise you further.

Regards,
Maria Ilieva
Telerik
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 the blog feed now.
0
Sarath
Top achievements
Rank 1
answered on 06 Dec 2013, 12:00 PM
Hi Maria,

   Thanks for your response.  

What we are facing the problem was from 5th column on wards by clicking any Filter column up to 10th columns  We are getting the error "Microsoft JScript runtime error: '_data' is null or not an object" (For first four columns filter column working properly). If you don't mind can you create few more columns in your solution under different headers (Totally 6 to 7 columns in Rad Grid) then you can check the error whether you are getting or not :-)

I have attached my UI screen shot.

Thanks for your patience!!!
0
Maria Ilieva
Telerik team
answered on 11 Dec 2013, 08:49 AM
Hi Sarath,

I tested the application by applying your recommendation and was able to replicate the issue locally. However after further discussing the issue with our development team it appears that this kind of adding header items to the RadGrid control is not supported scenario. You cold modify the current available column headers but adding spanned new header items in the header table would break the RadGrid functionality.
However I would suggest you to use the MultiColumn Headers feature which the RadGrid provides in order to achieve the required functionality. see the online resources below for more information on this feature and verify if it helps:
http://demos.telerik.com/aspnet-ajax/grid/examples/columns-rows/columns/multi-column-headers/defaultcs.aspx
http://www.telerik.com/help/aspnet-ajax/grid-multicolumn-headers.html


Regards,
Maria Ilieva
Telerik
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 the blog feed now.
Tags
Grid
Asked by
Sarath
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Sarath
Top achievements
Rank 1
Share this question
or