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

Modify Filter Value For ItemTemplate Column

2 Answers 170 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rodney
Top achievements
Rank 2
Rodney asked on 05 Apr 2017, 12:44 PM

I have a GridTemplateColumn that is defined as with a DateTime", but actually contains a link button. The value in the column is a date, but since the ItemTemplate is defined as a link button the actual filter value is a string. When you search if you enter a valid date value it will filter correctly, but if you enter a 2, for example, the SQL gets an error because you obviously can't compare 2 to a date field.

What I want to do is before the filter is performed validate that it is a valid date, if not just remove the filter. Additionally, I would really like to be able to add the date selector box next to the filter field. That would help in getting the date in the correct format.

Below is the definition for the column:

<telerik:GridTemplateColumn UniqueName="CREATEDON" DataField="CREATEDON" SortExpression="CREATEDON" HeaderText="Date Created" DataType="System.DateTime"
    CurrentFilterFunction="GreaterThanOrEqualTo" AutoPostBackOnFilter="true" HeaderStyle-Width="100">
    <ItemTemplate>
        <asp:LinkButton ID="lnkCreatedOn" runat="server" CommandName="VIEWTASK" CommandArgument='<%# Eval("TaskId") %>' OnClick="lnkCreatedOn_Click" />
    </ItemTemplate>
</telerik:GridTemplateColumn>

 

Thanks in advance.

Rodney

 

2 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 10 Apr 2017, 08:08 AM
Hi Rodney,

There are 2 options to achieve this requirement:

1. Use a FilterTemplate with a RadDatePicker:
http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/filtering/filter-templates/defaultcs.aspx

2. Replace the GridTemplateColumn with GridDateTimeColumn and add the LinkButtons manually during the ItemCreated event handler manually.

I hope this will prove helpful.

Regards,
Eyup
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Rodney
Top achievements
Rank 2
answered on 10 Apr 2017, 10:47 AM

Thank you so much, it worked perfectly.

Rodney

Tags
Grid
Asked by
Rodney
Top achievements
Rank 2
Answers by
Eyup
Telerik team
Rodney
Top achievements
Rank 2
Share this question
or