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

Find GridNumericColumn Filter control

3 Answers 143 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Praveen
Top achievements
Rank 1
Praveen asked on 28 Jun 2012, 05:10 PM
Hi,

I have a scenario where Age is one of the column in my grid. 
For that column I am using following syntax, and I am not using any ItemTemplate or FilterTemplate
<telerik:GridNumericColumn DataField="Age" FilterControlWidth="20px" UniqueName="Age"
               HeaderText="Age" EmptyDataText="-" HeaderStyle-HorizontalAlign="Center"
               DataType="System.Int32" MaxLength="3" FilterControlAltText="Age">
</telerik:GridNumericColumn>

And this column allow user to enter only numbers. I have requirement where I need to stop the user to not to give more than 3 digits.
Ultimately this header filter should allow user to enter only 3digit number. Suggest me how to achieve this? I have used MaxLength but this property is not used for this filter scenario.

I am thinking of finding that filter text box and adding a javascript method to it and handle that at client side, but I was not able to find the Filter text box Control. 

I would appreciate if any one help me find a solution. 

3 Answers, 1 is accepted

Sort by
0
Elliott
Top achievements
Rank 2
answered on 28 Jun 2012, 06:01 PM
did you investigate the FilterTemplate?  I have never used one but it looks promising

you may have to replace the GridNumericColumn with a GridTemplateColumn - the ItemTemplate should be a label and the EditItemTemplate a RadNumericTextBox
<telerik:GridTemplateColumn UniqueName="CashBack" HeaderText="CashBack" >
    <ItemTemplate>
        <asp:Label ID="lblCashBack" Text='<%# Bind("CashBack") %>' runat="server" />
    </ItemTemplate>
    <EditItemTemplate>
        <telerik:RadNumericTextBox ID="rntbCashBack" text='<%# Eval("CashBack") %>' runat="server">
            <NumberFormat DecimalDigits="2" />
        </telerik:RadNumericTextBox>
        <asp:RequiredFieldValidator ID="rfvCashBack" ControlToValidate="rntbCashBack" ErrorMessage="Required" runat="server" />
    </EditItemTemplate>
</telerik:GridTemplateColumn>
0
Praveen
Top achievements
Rank 1
answered on 28 Jun 2012, 08:11 PM
Marianne ,

Your code is totally different, in my scenario I don't have any edit template. In my grid I don't have any edit functionality, I would like to filter the data in grid using the Customized or Predefined filter controls.
In my case I could achieve all kind of filter implementation. But, I not finding a solution to get this implemented.

Simple grid, and header filter. One column is numeric column and for that numeric column filter I want to have validation [ie. it should allow maximum 3digit number

Thanks,
Praveen
0
Shinu
Top achievements
Rank 2
answered on 29 Jun 2012, 04:12 AM
Hello,

Try setting the MaxLength in Prerender event as shown below.
C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    GridFilteringItem item = (GridFilteringItem)RadGrid1.MasterTableView.GetItems(GridItemType.FilteringItem)[0];
    RadNumericTextBox txt = (RadNumericTextBox)item["Age"].Controls[0];
    txt.MaxLength = 3;
}

Thanks,
Shinu.
Tags
Grid
Asked by
Praveen
Top achievements
Rank 1
Answers by
Elliott
Top achievements
Rank 2
Praveen
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or