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

Not able to set MaxLength,TabOrder to RadDateInput

7 Answers 109 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Raji
Top achievements
Rank 1
Raji asked on 22 Nov 2011, 12:22 AM
Hi,

In my application, I am building the radgrid with custom filtering dynamically. I am using GridDateTimeColumn for data datatype. The grid puts in RadDateInput control as the filter for date. In RadGrid_ItemCreated event I am trying to set Maxlength and taborder to this control and it does not work. I am able to set for GridNumericColumn(RadNumericTextBox control) and GridBoundColumn(TextBox control).Help needed.

Thanks,
Raji

7 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 22 Nov 2011, 08:20 AM
Hello Raji,

Here is the sample code that I tried which worked as expected.
C#:
protected void RadGrid1_ItemCreated1(object sender, GridItemEventArgs e)
{
   if (e.Item is GridFilteringItem)
  {
   GridFilteringItem fitem = (GridFilteringItem)e.Item;
   RadDateInput input = (RadDateInput)fitem.FindControl("RadDateInput1");
   input.MaxLength = 8;
   input.TabIndex = 2;
  }
}

-Princy.
0
Raji
Top achievements
Rank 1
answered on 29 Nov 2011, 02:25 AM
Hi Princy,

I am building the grid dynamically and I do not know the control name. I tried using the below lines of code in RadGrid_itemCreated event

 

if

 

(e.Item is GridFilteringItem)

 

{

e.Item.VerticalAlign =

VerticalAlign.Top;

 

 

foreach (GridColumn nColumn in RadGrid1.MasterTableView.Columns)

 

{

 

 

 

 

if

 

(nColumn is GridDateTimeColumn)

 

{

 

GridFilteringItem filerItem = (GridFilteringItem)e.Item;

 

 

RadDateInput dateItem = (RadDateInput)filerItem[nColumn.UniqueName].Controls[1];

 

dateItem.DateFormat =

"MM/dd/yyyy";

 

dateItem.DisplayDateFormat =

"MM/dd/yyyy";

 

dateItem.MaxLength = 10;

 

dateItem.TabIndex = 10;

 

}
}

There is no errors but maxlength and tabindex is not set.

Thanks,
Raji

0
Maria Ilieva
Telerik team
answered on 01 Dec 2011, 04:40 PM
Hi Raji,

Could you please elaborate a bit more and let me know what is the exact functionality you need to achieve by setting MaxLength for the DateInput. As you have set a DateFormat for the input it will always show not more that 10 symbols in it. Even you try to type more than these symbols the control's parser will not allow them.
So actually adding this property is not needed in this case.


All the best,
Maria Ilieva
the Telerik team
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 their blog feed now
0
Raji
Top achievements
Rank 1
answered on 01 Dec 2011, 06:36 PM
Hi Maria,

I wanted to set the MaxLength and TabIndex for the filter control. I was able to do for the RadNumericTextBbox bot not for RadDateInput. The code shown below

protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
if (e.Item is GridFilteringItem)
        {
            e.Item.VerticalAlign = VerticalAlign.Top;            
            foreach (GridColumn nColumn in RadGrid1.MasterTableView.Columns)
            {
                nColumn.Resizable = false;
                  
                if (nColumn is GridNumericColumn)
                {
                    GridBoundColumn nBColumn = (GridBoundColumn)(nColumn);//  .GetProperty("MaxLength").
                    GridFilteringItem filerItem = (GridFilteringItem)e.Item;
                    RadNumericTextBox textItem = (RadNumericTextBox)filerItem[nColumn.UniqueName].Controls[0];
                    textItem.NumberFormat.GroupSeparator = "";
                    textItem.MaxLength = nBColumn.MaxLength; 
                            textItem.TabIndex=10;
                    textItem.InvalidStyle.BackColor = System.Drawing.Color.Red;
                    nColumn.CurrentFilterFunction = GridKnownFunction.EqualTo;
                                                                 
                }
                else if (nColumn is GridDateTimeColumn)
                {
                    GridBoundColumn nBColumn = (GridBoundColumn)(nColumn);
                    GridFilteringItem filerItem = (GridFilteringItem)e.Item;
                    RadDateInput dateItem = (RadDateInput)filerItem[nColumn.UniqueName].Controls[1];
                    RadDateInput dateItem1 = (RadDateInput)filerItem.FindControl(nColumn.UniqueName);
                    dateItem.DateFormat = "MM/dd/yyyy";
                    dateItem.DisplayDateFormat = "MM/dd/yyyy";
                    dateItem.MaxLength = nBColumn.MaxLength;
                    dateItem.TabIndex = 10;
                    nColumn.CurrentFilterFunction = GridKnownFunction.EqualTo;
                      
                }
                else if (nColumn is GridBoundColumn)
                {
                    GridBoundColumn nBColumn = (GridBoundColumn)(nColumn);
                    GridFilteringItem filerItem = (GridFilteringItem)e.Item;
                    TextBox textItem = (TextBox)filerItem[nColumn.UniqueName].Controls[0];
                    textItem.MaxLength = nBColumn.MaxLength; 
                           textItem.TabIndex=10;        
                    nColumn.CurrentFilterFunction = GridKnownFunction.Contains;
                    
                }
            }
}  
  
  
    }
0
Maria Ilieva
Telerik team
answered on 07 Dec 2011, 09:07 AM
Hello Raji,

As I previously mentioned setting a max length for the DateInput is not needed if you have DateFormat property set for the control. As for the TabIndex I noticed you have the same TabIndex for the other filter items. Please note that in order to have this TabIndex correctly applied you should make them different in order to arrange the controls in different order.

Greetings,
Maria Ilieva
the Telerik team
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 their blog feed now
0
Raji
Top achievements
Rank 1
answered on 07 Dec 2011, 05:24 PM
Hi Maria,

You can see from my code that I had set the DateFormat property for the RadDateInput control but still I can enter any number of characters. For RadNumericTextBox when I set the MaxLength it just allows that many characters. I did set the TabIndex different for the controls. After I set it and use the tab the cursor goes to all the filter controls except the RadDateInput control.

Thanks,
Raji
0
Maria Ilieva
Telerik team
answered on 12 Dec 2011, 02:49 PM
Hello Raji,


 I'd ask you to open up a formal support ticket and send us a fully runnable implementation of your project along with a back-up copy of the database. This will facilitate us to a great extent with pinpointing the issue and will guarantee you a faster response on our part.
 


Kind regards,
Maria Ilieva
the Telerik team
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 their blog feed now
Tags
Grid
Asked by
Raji
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Raji
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or