Nullable UInt32 From OpenAccessLinqDataSource Filtering Difficulties

2 posts, 0 answers
  1. Chris
    Chris avatar
    13 posts
    Member since:
    Oct 2010

    Posted 05 Feb 2015 Link to this post

    I have an OpenAccessLinqDataSource that pulls from some FK linked tables. The FK value is nullable (UInt32?) and while sorting works, I'm having some difficulties filtering.

    Here's my LinqDataSource
    <telerik:OpenAccessLinqDataSource ID="OA_Promos" Runat="server" ContextTypeName="Flow.ST2_Data" EntityTypeName="" OrderBy="ID desc" ResourceSetName="Promos" Select="new (ID, identifier, descriptor, lastUpdated, notes, startDate, endDate, startTime, endTime, priority, Promo_art.Art, Promo_art.width, Promo_art.height, Promo_art.fileName, Promo_topic.SpotID)" Where="Deleted == @Deleted" >
        <WhereParameters>
            <asp:Parameter DefaultValue="0" Name="Deleted" Type="Int16" />
        </WhereParameters>
    </telerik:OpenAccessLinqDataSource>

    The Promo_topic.SpotID is the column I'm trying to filter on using the following:
    <telerik:GridBoundColumn DataField="Promo_topic.SpotID" AllowFiltering="true" SortExpression="SpotID" CurrentFilterFunction="EqualTo" FilterControlAltText="Filter SpotID Column" AutoPostBackOnFilter="true" ShowFilterIcon="False" UniqueName="SpotID" HeaderText="Spot ID" DataType="System.UInt32"></telerik:GridBoundColumn>

    but I get 0 results returned when I filter on a valid Promo_topic.SpotID


    I tried custom filtering:
    <telerik:GridBoundColumn DataField="Promo_topic.SpotID" AllowFiltering="true" SortExpression="SpotID" CurrentFilterFunction="Custom" FilterControlAltText="Filter SpotID Column" AutoPostBackOnFilter="true" ShowFilterIcon="False" UniqueName="SpotID" HeaderText="Spot ID" DataType="System.UInt32"></telerik:GridBoundColumn>

    with the following ItemCommand event:
    protected void ItemCommandFired(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.FilterCommandName)
        {
            Pair filterPair = (Pair)e.CommandArgument;
            if (filterPair.First.ToString() == "Custom")
            {
                string colName = filterPair.Second.ToString();
                TextBox tbPattern = (e.Item as GridFilteringItem)[colName].Controls[0] as TextBox;
                e.Canceled = true;
                grid_promos.MasterTableView.FilterExpression = string.Format("(Promo_topic.SpotID.Equals({0})) AND (Promo_topic.SpotID != null)", tbPattern.Text);
                grid_promos.Rebind();
            }
        }
    }

    but then get the error "Methods on type 'UInt32?' are not accessible"

    Before I switch the entire DataLinqSource to reference a custom object, is there something I'm doing wrong?

    Thanks.
  2. Marin
    Admin
    Marin avatar
    1045 posts

    Posted 10 Feb 2015 Link to this post

    Hi,

    I do not see any problem with the filtering configuration of the grid columns. Indeed a custom filtering can also be tried in this case to verify what is the correct filter query necessary from the data source.
    If it is not accepting the filter query then it should probably be revised according to the OpenAccess requirements for constructing the query.

    Regards,
    Marin
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top