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

Custom Filtering JavaScript Error

1 Answer 145 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 27 Feb 2015, 06:27 AM
I followed this example to setup custom filtering in the Rad Grid: http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/filtering/filter-templates/defaultcs.aspx

This works, however when I pick an option it fails with this error:

0x800a138f - Microsoft JScript runtime error: Unable to get value of the property 'getElementsByClassName': object is null or undefined

The code (inside the filter as per the sample):

<telerik:GridBoundColumn UniqueName="Division" HeaderText="Division" DataField="Division.Division1" SortExpression="Division.Division1" AutoPostBackOnFilter="true" CurrentFilterFunction="EqualTo" ShowFilterIcon="true" ReadOnly="true">
                        <FilterTemplate>
                            <telerik:RadComboBox ID="RadComboBoxTitle" DataSourceID="edsDivision" DataValueField="DivisionID" DataTextField="Division1"
                                Height="200px" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("Division").CurrentFilterValue %>'
                                runat="server" OnClientSelectedIndexChanged="TitleIndexChanged">
                                <Items>
                                    <telerik:RadComboBoxItem Text="All" />
                                </Items>
                            </telerik:RadComboBox>
                            <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                                <script type="text/javascript">
                                    function TitleIndexChanged(sender, args) {
                                        var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                        tableView.filter("DivisionID", args.get_item().get_value(), "EqualTo");
                                    }
                                </script>
                            </telerik:RadScriptBlock>
                        </FilterTemplate>
                    </telerik:GridBoundColumn>

Division ID is a Foreign Key on the main table I'm using...

<asp:EntityDataSource ID="edsDivision" runat="server" ConnectionString="name=ERPEntities" DefaultContainerName="ERPEntities"
            EntitySetName="Divisions" EntityTypeFilter="Division" OrderBy="it.Division1"
            EnableInsert="false" EnableUpdate="false" EnableDelete="false">
        </asp:EntityDataSource>



args.get_item().get_value() = 3 in my example.



Line 476 of the Dynamic Javascipt is where it fails:

},getElementByClassName:function(d,c,g){if(d.getElementsByClassName){return d.getElementsByClassName(c)[0];

We are using IE9 in Standard IE9 mode.
Chrome and Firefox fail silently while Firefox reports a "TypeError: d is null"

How do I fix? 

1 Answer, 1 is accepted

Sort by
0
Peter
Top achievements
Rank 1
answered on 02 Mar 2015, 12:19 AM
I determined the cause of the problem: 

 tableView.filter("DivisionID", args.get_item().get_value(), "EqualTo");      

DivisionID is wrong about - this needed to be the Unique Column Name [like the "GetColumn" call above it].

As per the doco in the example URL above:

 filter(colUniqueName, valueToCompare, filterFunction)



Just wish the error message was better.
Tags
Grid
Asked by
Peter
Top achievements
Rank 1
Answers by
Peter
Top achievements
Rank 1
Share this question
or