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

Grid filter menu events? and a bit of globalization...

3 Answers 269 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hugues
Top achievements
Rank 1
Hugues asked on 05 Apr 2013, 04:23 PM
Are there any client side events available for events related to the filter popup menu of the grid?

We are currently using jquery Globalize(https://github.com/jquery/globalize) as a solution to our globalization requirement for our web app.

To keep number and date formats consistent accross the application we would like to use the plugin for the kendo ui grid as well (we're currently evaluating kendo ui as a replacement for the grid that we currently use). 

Our current grid exposes events such as FilterPopUp and FilterRequest. We need such client side events so that when a user interacts with the filter menu, we can format/unformat numbers/dates that the user interacts with in order to keep a standard format within the grid but display globalized values to users.

1) Does the Kendo UI Grid filter menu expose such events?

2) Has anyone successfuly implemented globalization without using the built in kendo globalization?


Thank you,

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 09 Apr 2013, 03:59 PM
Hello Hugues,

I am not sure if I understand correctly when the specified events are triggered. Could you clarify when the handlers for the "FilterPopUp" and "FilterRequest" events are called?
As general information I can say that the Grid exposes an event for the FilterMenu initialization and also allows to customize the inputs as demonstrated in this demo. 

Regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Hugues
Top achievements
Rank 1
answered on 09 Apr 2013, 04:14 PM
Hi Daniel,
I did end up finding the demo on customizable filter menus and I think we'll be able to use that as a solution.

The filter popup event happens when you click on the filter icon and before the filter menu is displayed which is the same as filterMenuInit so that works out.

The filter request event happens when the OK button (or whichever button is clicked to apply the filtering) is clicked and before the data is sent to the server. It allows us to work with the values on the client side before they are sent to the server. Can this be done?

Thank you much for your help!
0
Daniel
Telerik team
answered on 11 Apr 2013, 01:01 PM
Hi again Hugues,

The Grid does not have a specific event that is triggered when it is being filtered but the dataSource transport parameterMap function is triggered each time a request is being made so that the values can be converted to the needed format. The function is not exposed by the Kendo MVC DataSource because a default parameterMap function is used which converts the values in the format that is expected by the DataSourceRequestAttribute. It is possible to override the function via JavaScript after the Grid has been initialized as demonstrated in the snippet below:

$(document).ready(function () {
    var grid = $("#GridName").data("kendoGrid"),
        mvcTransport = new kendo.data.transports["aspnetmvc-ajax"]();
 
    grid.dataSource.transport.parameterMap = function (options, type) {
        if (type == "read" && options.filter) {
            updateFilterValues(options.filter);
        }
 
        return mvcTransport.parameterMap(options, type);
    };
});
 
function updateFilterValues(filter) {
    if (filter.filters) {
        for (var i = 0; i < filter.filters.length; i++) {
            updateFilterValues(filter.filters[i]);
        }
    }
    else {
        changeValueForField(filter.field, filter.value);
    }
}
An alternative is to get the filters and modify the values on the server from the DataSourceRequest before using the ToDataSourceResult method. Regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Hugues
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Hugues
Top achievements
Rank 1
Share this question
or