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

2 Filter questions/issues

6 Answers 117 Views
Filter
This is a migrated thread and some comments may be shown as answers.
Brett
Top achievements
Rank 1
Brett asked on 05 Feb 2011, 12:44 AM
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.

6 Answers, 1 is accepted

Sort by
0
Brett
Top achievements
Rank 1
answered on 08 Feb 2011, 01:25 AM
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.
0
Accepted
Martin
Telerik team
answered on 10 Feb 2011, 01:07 PM
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.
0
Brett
Top achievements
Rank 1
answered on 10 Feb 2011, 10:06 PM
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]);
    }
}
0
Brett
Top achievements
Rank 1
answered on 11 Feb 2011, 01:28 AM
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.
0
Martin
Telerik team
answered on 16 Feb 2011, 12:41 PM
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.
0
Brett
Top achievements
Rank 1
answered on 16 Feb 2011, 07:26 PM
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.
Tags
Filter
Asked by
Brett
Top achievements
Rank 1
Answers by
Brett
Top achievements
Rank 1
Martin
Telerik team
Share this question
or