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

Grid filtering

6 Answers 223 Views
Grid
This is a migrated thread and some comments may be shown as answers.
rizk
Top achievements
Rank 1
rizk asked on 23 Mar 2009, 10:25 AM
hey,
       i am encountering this exception while trying to enable grid filtering,
'GridItem' is a type and cannot be used as an expression.

<telerik:GridBoundColumn HeaderText="<%$Resources:Created %>" UniqueName="Created"
                                        SortExpression="PostDate" DataField="PostDate" DataFormatString="<%$Resources:DateFormat %>">
                                        <FilterTemplate>
                                            From
                                            <telerik:RadDatePicker ID="FromOrderDatePicker" runat="server" Width="85px" ClientEvents-OnDateSelected="FromDateSelected"
                                                MinDate="01-01-1900" FocusedDate='<%#Eval("Status.Title") %>' DbSelectedDate='<%#Eval("Status.Title") %>' />
                                            to
                                            <telerik:RadDatePicker ID="ToOrderDatePicker" runat="server" Width="85px" ClientEvents-OnDateSelected="ToDateSelected"
                                                MinDate="01-01-1900" FocusedDate='<%#Eval("Status.Title") %>' DbSelectedDate='<%#Eval("Status.Title") %>' />
                                            <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">

                                                <script type="text/javascript">
                                                    function FromDateSelected(sender, args) {
                                                        var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");

                                                        var date = FormatSelectedDate(sender);

                                                        tableView.filter("OrderDate", date, "GreaterThanOrEqualTo");

                                                    }
                                                    function ToDateSelected(sender, args) {
                                                        var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");

                                                        var date = FormatSelectedDate(sender);

                                                        tableView.filter("OrderDate", date, "LessThanOrEqualTo");
                                                    }
                                                    function FormatSelectedDate(picker) {
                                                        var date = picker.get_selectedDate();
                                                        var dateInput = picker.get_dateInput();
                                                        var formattedDate = dateInput.get_dateFormatInfo().FormatDate(date, dateInput.get_displayDateFormat());

                                                        return formattedDate;
                                                    }
                                                </script>

                                            </telerik:RadScriptBlock>
                                        </FilterTemplate>
                                    </telerik:GridBoundColumn>
any help please

6 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 26 Mar 2009, 11:26 AM
Hello Rizk,

Unfortunately I could not reproduce the described error. In my attempt to replicate this issue I created a test project which implements your scenario. Please examine it and let me know if I am missing something.

For further information I will suggest you review the C# and VB version of this online demo.

Best regards,
Georgi Krustev
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Lenny_shp
Top achievements
Rank 2
answered on 02 Apr 2009, 07:38 PM
I have the same problem with Q1 2009.~26nbsp~3b The difference is that I have a master and detail table and custom date filter is on the master table.~26nbsp~3b~26nbsp~3b Your example doesn~27t have a detail table. ~26nbsp~3b I don~27t know if that is the cause.~3cbr /~3e ~3cbr /~3e ~28there is a problem with this Format Code Block in editor..~29~3cbr /~3e
0
Georgi Krustev
Telerik team
answered on 06 Apr 2009, 09:14 AM
Hi Lenny,

I took into account of your note, but I still cannot reproduce the depicted issue. If the problem persists please use the attached example as base in order to replicate the erroneous behavior. Feel free to open a regular support ticket and attach the modified project to it. Thus we will be able to investigate the problem further and provide more to-the-point answer.

Kind regards,
Georgi Krustev
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Elfman
Top achievements
Rank 1
answered on 17 Apr 2009, 04:18 PM
I got this same error also after copying the example right off the web page. for the q1 2009  version.
I previously had a custom filter in the grid, but after upgrading it no longer posted back.
So I thought I'd try the new way  ..... but I got

Compiler Error Message: BC30108: 'GridItem' is a type and cannot be used as an expression.

This is the sample but it is for C#
<%# ((GridItem)Container).OwnerTableView.GetColumn("Status").CurrentFilterValue %>

In VB I needed:

'

 

<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("Status").CurrentFilterValue %>'

 



0
Karl
Top achievements
Rank 1
answered on 14 Aug 2009, 10:07 AM
Did any one find a solution to this?

Thanks
0
GlenB
Top achievements
Rank 1
answered on 14 May 2010, 05:56 AM
I just had the same problem, and found that Elfman had supplied the solution (for VB) as follows:

Replace
SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("ContactTitle").CurrentFilterValue %>' 
with
SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("ContactTitle").CurrentFilterValue %>' 

and also:
Replace
var tableView=$find("<%# ((GridItem)Container).OwnerTableView.ClientID %>"); 
with
var tableView = $find("<%# TryCast(Container,GridItem).OwnerTableView.ClientID %>"); 

Hope this makes it a little clearer for anyone else...
Tags
Grid
Asked by
rizk
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Lenny_shp
Top achievements
Rank 2
Elfman
Top achievements
Rank 1
Karl
Top achievements
Rank 1
GlenB
Top achievements
Rank 1
Share this question
or