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

Cannot call method '_showFilterMenu' of null

1 Answer 263 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gökhan
Top achievements
Rank 1
Gökhan asked on 16 Jun 2012, 01:40 AM
Hi,

I have a RadGrid and I fill my data on it. First time i can filter my column but second time it gives "Cannot call method '_showFilterMenu' of null " message when i click filter button. My codes is follow..

and i attached my screenshot result..
 

using
 System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Getron.AAM.EntityManagement;
using System.Data;
using Telerik.Web.UI;
using Getron.Core.BussinesRuleEngine;
using Getron.Core.Base.Web;
using System.Text;
 
public partial class Sections_TaskManagement_Controls_SelectRows : EntityProtectedUserControl
{
 
    private void Page_Load(object sender, System.EventArgs e)
    {
         
            if (Request.QueryString["ControlIntCode"] != null && Getron.Core.Tools.DataTableFieldOperation.ToInt64(Request.QueryString["ControlIntCode"].ToString(), 0) > 0)
            {
                RequestTemplateControl templateControl = new RequestTemplateControl(Getron.Core.Tools.DataTableFieldOperation.ToInt64(Request.QueryString["ControlIntCode"].ToString(), 0));
                 
                SqlDataSource1.ConnectionString = templateControl.DbSession.Connection.ConnectionString;
                SqlDataSource1.SelectCommand = templateControl.Query;
 
 
                this.RadGrid1.MasterTableView.Columns.Clear();
 
                GridClientSelectColumn selectCol = new GridClientSelectColumn();
 
                this.RadGrid1.MasterTableView.Columns.Add(selectCol);
             
        }
 
    }
 
}



<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SelectRows.ascx.cs" Inherits="Sections_TaskManagement_Controls_SelectRows" %>
 
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Hay" />
     
 
        <script type="text/javascript">
        function GetRadWindow()
        {
            var oWindow = null;
            if (window.radWindow) oWindow = window.radWindow;
            else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
            return oWindow;
        }
 
        function returnToParent() {
            //create the argument that will be returned to the parent page
            var oArg = new Object();
 
            //get the city's name
            oArg.cityName = "deneme";
 
            //get the selected date from RadDatePicker
             
            //oArg.selDate = datePicker.get_selectedDate().toLocaleDateString();
 
            //get a reference to the current RadWindow
            var oWnd = GetRadWindow();
 
 
 
 
            //Close the RadWindow and send the argument to the parent page
            if (oArg.selDate && oArg.cityName) {
                oWnd.close(oArg);
            }
            
        }
    </script>
 
     
        <telerik:RadGrid AutoGenerateColumns="true" ID="RadGrid1" DataSourceID="SqlDataSource1" EnableTheming="true"
        Width="760px" AllowFilteringByColumn="True" AllowSorting="True" PageSize="15"
        ShowFooter="True" AllowPaging="True" runat="server" GridLines="None" EnableLinqExpressions="false">
        <PagerStyle Mode="NextPrevAndNumeric" />
        <GroupingSettings CaseSensitive="false" />
        <MasterTableView  AllowFilteringByColumn="True"
            ShowFooter="True" TableLayout="Auto"></MasterTableView>
            <ClientSettings>
            <Selecting AllowRowSelect="true" />
             
            </ClientSettings>
             
        </telerik:RadGrid>
        <asp:SqlDataSource ID="SqlDataSource1"
        ProviderName="System.Data.SqlClient"  runat="server">
    </asp:SqlDataSource>
    <hr />
    <button title="Submit" id="close" onclick="returnToParent(); return false;">Seçilenleri Onayla</button>




1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 21 Jun 2012, 05:35 AM
Hello,

Most probably the problem comes from the fact that you are clearing the Columns collection of RadGrid in the Page_Load event.

Doing this, the first time noting happens, because the structure of RadGrid is still not created, however, on the second time, the structure is recreated from the ViewState. And after that you are clearing the collection and most probably this is the reason for the error message.

Please, check this help topic for more information on how to create the structure of RadGrid dynamically. Additionally, you do not need to create the ClientSelectColumn dynamically in this case, you could do it statically in mark-up code.

Give these suggestions a try and check whether the issue still replicates.
Regards,
Andrey
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
Grid
Asked by
Gökhan
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or