Unknown params when using column filterable

5 posts, 2 answers
  1. Jacob
    Jacob avatar
    45 posts
    Member since:
    Sep 2014

    Posted 23 Jan 2015 Link to this post

    Hi,

    Working with MVC5 and Kendo().Grid.
    Using filter on columns, won't fire the javascript function with the right params or I don't understand how to !!
    The aim is to remove the decimals from the integer in the filter box.

    This is what I have:
    .Columns(columns =>
        {
            columns.Bound(e => e.InternalId).Width(60).Filterable(filter => filter.UI("NumericFilter()"));
        })

    -and the function:
    function NumericFilter(control) {
        alert ("Got here...");
        $(control).kendoNumericTextBox({ "format": "n0", "decimals": 0 });
    }

    When the function is called, the param is null. If removing the parentheses from the function name in the filter definitions, the call is not fired at all.
    The above code is found somewhere else on this site.
    Thanks.
  2. Answer
    Rosen
    Admin
    Rosen avatar
    3253 posts

    Posted 26 Jan 2015 Link to this post

    Hi Jacob,

    The UI method should specify the only name of the function, thus you should remove the parentheses. However, note that the filter.UI will be executed only when the filter mode is Menu. Therefore, you should check in which mode the grid in question is set. If the mode is Row, you will need to use Template option instead:

    .Filterable(ftb => ftb.Cell(cell => cell.Template("NumericFilter")))


    Regards,
    Rosen
    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.

     
  3. Jacob
    Jacob avatar
    45 posts
    Member since:
    Sep 2014

    Posted 26 Jan 2015 in reply to Rosen Link to this post

    Hi Rosen,

    That did change something, but the decimals are still not removed.
    This line:
    $(control).kendoNumericTextBox({ "format": "n0", "decimals": 0 });
    -seems to be wrong.
    Could you please put me in the right direction.
    Thanks :-)
  4. Jacob
    Jacob avatar
    45 posts
    Member since:
    Sep 2014

    Posted 26 Jan 2015 in reply to Rosen Link to this post

    An another side effect of using ".Filterable(ftb => ftb.Cell(cell => cell.Template("NumericFilter")))" is that the textbox layout is lost, why ??
  5. Answer
    Rosen
    Admin
    Rosen avatar
    3253 posts

    Posted 27 Jan 2015 Link to this post

    Hi Jacob,

    The signature of the function used with Filterable Row mode is different than the one used when in Menu mode. Therefore, you will need to change the code similar to the following:

    function NumericFilter(e) {
        alert ("Got here...");
        $(e.element).kendoNumericTextBox({ "format": "n0", "decimals": 0 });
    }


    Regards,
    Rosen
    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.

     
Back to Top