Grid filtering

7 posts, 0 answers
  1. rizk
    rizk avatar
    8 posts
    Member since:
    Aug 2007

    Posted 23 Mar 2009 Link to this post

    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
  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 26 Mar 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Lenny_shp
    Lenny_shp avatar
    343 posts
    Member since:
    Jul 2006

    Posted 02 Apr 2009 Link to this post

    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
  5. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 06 Apr 2009 Link to this post

    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.
  6. Elfman
    Elfman avatar
    12 posts
    Member since:
    Feb 2007

    Posted 17 Apr 2009 Link to this post

    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 %>'

     



  7. Karl
    Karl avatar
    172 posts
    Member since:
    Jun 2009

    Posted 14 Aug 2009 Link to this post

    Did any one find a solution to this?

    Thanks
  8. GlenB
    GlenB avatar
    37 posts
    Member since:
    Apr 2010

    Posted 14 May 2010 Link to this post

    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...
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017