How to custom filter ASP.NET Telerik RadGrid date columns

Share

The Telerik RadGrid for ASP.NET Ajax allows custom filtering on date columns by using JavaScript.

The user will normally need to be able to filter the date columns by writing a date inside the RadDateInput control and then pressing a key (e.g. Enter) or by choosing a date from the DatePicker filter control. Date validation can be done before actually doing the filtering. Also, other checks can be performed according to the logic of the application.

RadGrid datepicker filter

The desired functionality is achieved using the OnDateSelected client side event of the DatePicker.

The date format of the controls on the date column can be changed according to the culture or whatever logic.

The aspx page code can look like this:









The JavaScript function where the custom logic will be performed is the following:
function filterDateOnDateSelected(sender, gvwColName, filterFunction) {
var masterTableView = $find('').get_masterTableView();
var dtInput = sender.get_dateInput();
var dateValue = dtInput.get_value();
//custom validations can be done here
if (dateValue != "") {
masterTableView.filter(gvwColName, dateValue, filterFunction);
} else {
masterTableView.filter(gvwColName, dateValue, Telerik.Web.UI.GridFilterFunction.NoFilter);
}
}

Using the ItemCreated server side event of the grid, the date format is set and the javascript function is assigned to the column.

protected void gridDate_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridFilteringItem) {
RadDatePicker picker = ((GridFilteringItem)e.Item)["DateColumn"].Controls[0] as RadDatePicker;
if (picker != null) {
picker.DateInput.DisplayDateFormat = "dd.MM.yyyy";
picker.DateInput.DateFormat = "dd.MM.yyyy";
picker.ClientEvents.OnDateSelected = "function(sender, args) { filterDateOnDateSelected(sender,'DateColumn',Telerik.Web.UI.GridFilterFunction.GreaterThanOrEqualTo); }";
}
}
}

Finally, there’s another very important peculiarity of what does Cialis that brings it so high above its alternatives. It is the only med that is available in two versions – one intended for use on as-needed basis and one intended for daily use. As you might know, Viagra and Levitra only come in the latter of these two forms and should be consumed shortly before expected sexual activity to ensure best effect. Daily Cialis, in its turn, contains low doses of Tadalafil, which allows to build its concentration up in your system gradually over time and maintain it on acceptable levels, which, consequently, makes it possible for you to enjoy sex at any moment without having to time it.

1 thought on “How to custom filter ASP.NET Telerik RadGrid date columns”
  • trytry says:

    trytr

    July 8, 2011 at 9:02 pm

Comments are closed.

By continuing to use the site, you agree to the use of cookies. More information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close