This is a migrated thread and some comments may be shown as answers.
AutoPostBackOnFilter failing
1 Answer 48 Views
This is a migrated thread and some comments may be shown as answers.
Chamara
Top achievements
Rank 1
Chamara asked on 15 Jul 2013, 03:54 AM
I have auto generated columns in my radgrid and i'm trying to enable column filtering on enter key press. when i type search text and press enter i'm getting the following error.
Uncaught TypeError: Cannot read property 'value' of null
<telerik:RadGrid ID="gridSearchL3" runat="server" AllowPagg="True" 
             GridLines="None" Height="415px" 
             OnNeedDataSource="RadGrid1_NeedDataSource"
            Font-Names="Eras Medium ITC" Font-Size="Small" PageSize="50" 
             AllowFilteringByColumn="True"
           
             AllowSorting="True" ShowStatusBar="True" AllowPaging="True" CellSpacing="0" 
                oncolumncreated="gridSearchL3_ColumnCreated1" onitemcommand="gridSearchL3_ItemCommand" 
                >
               <FilterItemStyle Font-Names="Eras Medium ITC" Font-Size="XX-Small" />
               <GroupingSettings CaseSensitive="False" />
            <ExportSettings Excel-Format="ExcelML" ExportOnlyData="True" 
                FileName="PinC Group" IgnorePaging="True" OpenInNewWindow="True">
                <Excel Format="ExcelML" />
            </ExportSettings>
            <ClientSettings>
              
                <Selecting AllowRowSelect="True" />
                <Scrolling AllowScroll="True" UseStaticHeaders="True" />
                    
            </ClientSettings>
            <AlternatingItemStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" />
            <GroupHeaderItemStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" />
            <SortingSettings EnableSkinSortStyles="false" /> 
            <MasterTableView  Font-Names="Eras Medium ITC" 
                   Font-Size="X-Small">
           
                <CommandItemSettings  ExportToPdfText="Export to Pdf" />
                 
                <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                </RowIndicatorColumn>
                <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                </ExpandCollapseColumn>
             
                <EditFormSettings>
                    <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                    </EditColumn>
                </EditFormSettings>
                <ItemStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" />
                <PagerStyle Mode="NextPrevNumericAndAdvanced" />
                <FilterItemStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" />
            </MasterTableView>
            <EditItemStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" />
            <FooterStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" />
            <HeaderStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" />
            <FilterItemStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" />
               <CommandItemStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" />
               <ActiveItemStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" />
               <ItemStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" />
               <PagerStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" 
                   HorizontalAlign="Left" Mode="NextPrevNumericAndAdvanced" />
               <SelectedItemStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" />
               <FilterMenu Font-Names="Eras Medium ITC" Font-Size="X-Small" 
                 EnableRoundedCorners="True">
               </FilterMenu>
               <HeaderContextMenu Font-Names="Eras Medium ITC" Font-Size="X-Small" 
                   Skin="Simple">
               </HeaderContextMenu>
               </telerik:RadGrid>

code behind:

public void setSqlDatSource()
    {

        gridSearchL3.DataSource = getsource();

    }


public DataTable getsource()
    {
        string Query;

        Query = @"select distinct h.DocumentNumber 'Document Number' " +
                 " from tblDocumentHeader h    where  h.DocumentHeaderTypeID=3 ";

        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["PinCBusMgtDocs.Properties.Settings.PINCConnectionString"].ConnectionString);
        DataTable dt = new DataTable();
        using (SqlDataAdapter da = new SqlDataAdapter(Query, con))
        {
            
            da.Fill(dt);
        }

        return dt;
    }


protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {

      setSqlDatSource();
  
    }

    protected void gridSearchL3_ColumnCreated1(object sender, GridColumnCreatedEventArgs e)
    {
       if (e.Column.UniqueName == "Document Number")
        {
            e.Column.FilterControlWidth = 120;
            e.Column.HeaderStyle.Width = Unit.Pixel(120);
            e.Column.AutoPostBackOnFilter = true;
            e.Column.CurrentFilterFunction = GridKnownFunction.Contains;
         }
     
        }

             
    }





































































 

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 15 Jul 2013, 05:56 AM
Hello,

Please try with the below code snippet.

<telerik:RadGrid ID="gridSearchL3" runat="server" AllowPagg="True" GridLines="None"
       OnNeedDataSource="RadGrid1_NeedDataSource" Font-Names="Eras Medium ITC" Font-Size="Small"
       PageSize="50" AllowFilteringByColumn="True" AllowSorting="True" ShowStatusBar="True"
       AllowPaging="True" CellSpacing="0" OnColumnCreated="gridSearchL3_ColumnCreated1" EnableLinqExpressions="false">
       <FilterItemStyle Font-Names="Eras Medium ITC" Font-Size="XX-Small" />
       <GroupingSettings CaseSensitive="False" />
       <ExportSettings Excel-Format="ExcelML" ExportOnlyData="True" FileName="PinC Group"
           IgnorePaging="True" OpenInNewWindow="True">
           <Excel Format="ExcelML" />
       </ExportSettings>
       <ClientSettings>
           <Selecting AllowRowSelect="True" />
           <Scrolling AllowScroll="True" UseStaticHeaders="True" />
       </ClientSettings>
       <AlternatingItemStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" />
       <GroupHeaderItemStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" />
       <SortingSettings EnableSkinSortStyles="false" />
       <MasterTableView Font-Names="Eras Medium ITC" Font-Size="X-Small">
           <CommandItemSettings ExportToPdfText="Export to Pdf" />
           <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
           </RowIndicatorColumn>
           <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
           </ExpandCollapseColumn>
           <EditFormSettings>
               <EditColumn FilterControlAltText="Filter EditCommandColumn column">
               </EditColumn>
           </EditFormSettings>
           <ItemStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" />
           <PagerStyle Mode="NextPrevNumericAndAdvanced" />
           <FilterItemStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" />
       </MasterTableView>
       <EditItemStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" />
       <FooterStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" />
       <HeaderStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" />
       <FilterItemStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" />
       <CommandItemStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" />
       <ActiveItemStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" />
       <ItemStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" />
       <PagerStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" HorizontalAlign="Left"
           Mode="NextPrevNumericAndAdvanced" />
       <SelectedItemStyle Font-Names="Eras Medium ITC" Font-Size="X-Small" />
       <FilterMenu Font-Names="Eras Medium ITC" Font-Size="X-Small" EnableRoundedCorners="True">
       </FilterMenu>
       <HeaderContextMenu Font-Names="Eras Medium ITC" Font-Size="X-Small" Skin="Simple">
       </HeaderContextMenu>
   </telerik:RadGrid>
public void setSqlDatSource()
    {
 
        gridSearchL3.DataSource = getsource();
 
    }
 
 
    public DataTable getsource()
    {
 
        DataTable dt = new DataTable();
        dt.Columns.Add("Shipper", typeof(string));
        dt.Columns.Add("ShipperTemp", typeof(string));
        dt.Columns.Add("DocumentNumber", typeof(string));
        dt.Rows.Add("CShipper1", "1", "DocumentNumber1");
        dt.Rows.Add("BShipper2", "2", "DocumentNumber2");
        dt.Rows.Add("AShipper3", "3", "DocumentNumber3");
        dt.Rows.Add("EShipper4", "4", "DocumentNumber4");
        dt.Rows.Add("DShipper5", "5", "DocumentNumber5");
 
        return dt;
    }
 
 
    protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
 
        setSqlDatSource();
 
    }
 
    protected void gridSearchL3_ColumnCreated1(object sender, GridColumnCreatedEventArgs e)
    {
        if (e.Column.UniqueName == "DocumentNumber")
        {
            e.Column.FilterControlWidth = 120;
            e.Column.HeaderStyle.Width = Unit.Pixel(120);
            e.Column.AutoPostBackOnFilter = true;
            e.Column.CurrentFilterFunction = GridKnownFunction.Contains;
            e.Column.HeaderText = "Document Number";
        }
    }


Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Chamara
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or