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

Default filter & make read Only

1 Answer 52 Views
Filter
This is a migrated thread and some comments may be shown as answers.
rik butcher
Top achievements
Rank 1
rik butcher asked on 17 Dec 2013, 04:24 PM
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();

 

 

 

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 20 Dec 2013, 02:08 PM
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.
Tags
Filter
Asked by
rik butcher
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or