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

Nullable UInt32 From OpenAccessLinqDataSource Filtering Difficulties

1 Answer 30 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 05 Feb 2015, 04:21 PM
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.

1 Answer, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 10 Feb 2015, 10:00 AM
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.

 
Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Marin
Telerik team
Share this question
or