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

4 posts, 0 answers
  1. Hugues
    Hugues avatar
    5 posts
    Member since:
    Nov 2011

    Posted 05 Apr 2013 Link to this post

    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,
  2. Daniel
    Admin
    Daniel avatar
    2231 posts

    Posted 09 Apr 2013 Link to this post

    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!
  3. Hugues
    Hugues avatar
    5 posts
    Member since:
    Nov 2011

    Posted 09 Apr 2013 Link to this post

    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!
  4. Daniel
    Admin
    Daniel avatar
    2231 posts

    Posted 11 Apr 2013 Link to this post

    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!
Back to Top