2 Filter questions/issues

7 posts, 1 answers
  1. Brett
    Brett avatar
    8 posts
    Member since:
    Feb 2011

    Posted 04 Feb 2011 Link to this post

    Using Telerik RADControls for ASP.NET AJAX Q2 2010 SP2.

    1) Inputting an integer larger than 70 billion in any filter expression (roughly, hold down any number key for a few seconds, you will see).  This can be reproduced on the live demo here: http://demos.telerik.com/aspnet-ajax/filter/examples/firstlook/defaultcs.aspx  The demo page redirects to a page not found, but in a VS project in debug mode, it will return a javascript error where it basically says "Value too large for System.Int32".  Is there a solution for this via javascript or C#?  Basically cap the number of digits user can enter for an integer type filter expression.

    2) I need to remove the following items from a filter expression: "NotEqualTo", "GreaterThan", "LessThan", "GreaterThanOrEqualTo", "LessThanOrEqualTo", "Between" and "NotBetween" but ONLY for string columns, these are still needed for integer columns.
  2. Brett
    Brett avatar
    8 posts
    Member since:
    Feb 2011

    Posted 07 Feb 2011 Link to this post

    Solved issue 1: Apparently the RadFilter ignores the DataType attribute on the RadGrid columns and defaults to 2^46.  This was fixed by traversing the RadFilter's controls recursively from Page_PreRender looking for all RadNumericTextBox child controls and setting their MaxValue property to System.UInt32.MaxValue - 1.

    private void RecursiveCleanseFilters(Control c)
            {
                for (int i = 0; i < c.Controls.Count; i++)
                {
                    if (c.Controls[i] is RadNumericTextBox)
                    {
                        RadNumericTextBox rntb = c.Controls[i] as RadNumericTextBox;
                        rntb.MaxValue = System.UInt32.MaxValue - 1;
                    }
      
                    this.RecursiveCleanseFilters(c.Controls[i]);
                }
            }

    As much as I dislike recursive solutions, this is the only way I can see to ensure you get all additional FilterExpressions within the root.

    Issue 2 still up for grabs.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Martin
    Admin
    Martin avatar
    811 posts

    Posted 10 Feb 2011 Link to this post

    Hello Brett,

    One option to hide some of the items of the RadFilter's context menu is to add a custom handler for its OnClientShowing event. Here is a sample code that will remove the IsNull and NotIsNull options for fields that are bound to System.Int32 data:

    function pageLoad()
    {
        var filter = $find("<%=RadFilter1.ClientID %>");
        filter.get_contextMenu().add_showing(function (sender, args)
        {
            var currentExpandedItem = sender.get_attributes()._data.ItemHierarchyIndex;
            var fieldName = filter._expressionItems[currentExpandedItem];
            var allFields = filter._dataFields;
            var dataType = null;
            for (var i = 0, j = allFields.length; i < j; i++)
            {
                if (allFields[i].FieldName == fieldName)
                {
                    dataType = allFields[i].DataType; break;
                }
            }
            if (dataType == "System.Int32")
            {
                sender.findItemByValue("IsNull").set_visible(false);
                sender.findItemByValue("NotIsNull").set_visible(false);
            }
        });
     
    }

    I hope this helps.

    Best wishes,
    Martin
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  5. Brett
    Brett avatar
    8 posts
    Member since:
    Feb 2011

    Posted 10 Feb 2011 Link to this post

    That worked perfectly; by modifying my recursive function slightly and adding that client event to the context menu.  Since these context menus can be in various levels of the base filter, this again seems to be the only good solution.  On a Intel Core 2 Duo it only took about 1000 ticks to traverse about 10 expression items, so this wont really kill performance if anyone else decides to use this.

    public static void RecursiveCleanseFilters(Control c)
    {
        for (int i = 0; i < c.Controls.Count; i++)
        {
            else if (c.Controls[i] is RadNumericTextBox)
            {
                RadNumericTextBox rntb = c.Controls[i] as RadNumericTextBox;
                rntb.MaxValue = System.UInt32.MaxValue - 1;
            }
            else if (c.Controls[i] is RadFilterContextMenu)
            {
                RadFilterContextMenu rfcm = c.Controls[i] as RadFilterContextMenu;
                rfcm.OnClientShowing = "pageLoad";
            }
            RecursiveCleanseFilters(c.Controls[i]);
        }
    }
  6. Brett
    Brett avatar
    8 posts
    Member since:
    Feb 2011

    Posted 10 Feb 2011 Link to this post

    One more quick question, is there a way to replace the inline $find() with a selector instead?  I have tried $('div[class^="RadFilter"]') and it finds the element fine, however it does not have the same methods as what $find() returns.

    The reason I want to do this is so I can move the javascript out into a seperate js file so that it can be used across multiple pages with various filters with various ids.
  7. Martin
    Admin
    Martin avatar
    811 posts

    Posted 16 Feb 2011 Link to this post

    Hello Brett,

    Note that the $find() method returns the client-side object of the RadFilter and not its DOM element. Its is the client side object that implements the get_contextMenu() method.

    Best wishes,
    Martin
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  8. Brett
    Brett avatar
    8 posts
    Member since:
    Feb 2011

    Posted 16 Feb 2011 Link to this post

    I see, that makes sense why it didnt work.  Fortunately I found a different way to approach this and still be able to use $find().  Thanks for all the help.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017