Default filter & make read Only

2 posts, 0 answers
  1. rik butcher
    rik butcher avatar
    106 posts
    Member since:
    Jul 2009

    Posted 17 Dec 2013 Link to this post

    guys, I've  got a rad filter w/ several filters in there - for this purpose only one of the field editors is shown.
    in the code behind for this filter in the OnItemCommand, i'm able to default it to zero - is there a way to also make this one filter "read only"
    when it's chosen? or would I need a special "custom class"?
    thanks for any Help on this.
    rik

    <telerik:RadFilter ID="WorkOrderItemsRadFilter" runat="server" Skin="WebBlue" ShowApplyButton="true"

    OnApplyExpressions="WorkOrderItemsRadFilter_Apply" ApplyButtonText="Filter Work Order Items"

    OnPreRender="WorkOrderItemsRadFilter_PreRender" OnFieldEditorCreating="RadFilter_FieldEditorCreating" OnItemCommand="WorkOrderItemsRadFilter_ItemCommand">

    <FieldEditors>

    <telerik:RadFilterNumericFieldEditor FieldName="MATERIALGRADEID" DisplayName="Empty Grade" DataType="System.Int32" />
    </FieldEditors>
    </telerik:RadFilter>
    CODE BEHIND IN THE ON ITEM COMMAND - TAKEN OUT OF CONTEXT:

    else if (myCmdArg == "MATERIALGRADEID")

    {

    e.Canceled = true;

    RadFilterStartsWithFilterExpression item = new RadFilterStartsWithFilterExpression(e.CommandArgument.ToString());

    //replace the current item with the new item that has the default filter set to StartsWith

    int i = e.ExpressionItem.ItemIndex;

    e.ExpressionItem.OwnerGroup.Expression.Expressions.RemoveAt(i);

    e.ExpressionItem.OwnerGroup.Expression.Expressions.Insert(i, item);

    item.Value = "0";//DEFAULT THIS TO ZERO

    WorkOrderItemsRadFilter.RecreateControl();

     

     

     

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 20 Dec 2013 Link to this post

    Hi Rik,

    In order to make the input in the FieldEditor read only you could use the ExpressionItemCreated event. You need to check if the field name is the one you need and disable the input control. The handler would look similar to the one below:

    protected void WorkOrderItemsRadFilter_ExpressionItemCreated(object sender, RadFilterExpressionItemCreatedEventArgs e)
    {
        if (e.Item is RadFilterSingleExpressionItem)
        {
            var item = e.Item as RadFilterSingleExpressionItem;
     
            if (item.FieldName == "MATERIALGRADEID")
            {
                (item.InputControl as RadNumericTextBox).ReadOnly = true;
            }
        }
    }



    Regards,
    Viktor Tachev
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top