We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

GridNumericColumn restrict maximum number of characters allowed in EditMode

Thread ID:

Created:

Updated:

Platform:

Replies:

118828 Apr 13,2015 02:26 PM Apr 23,2015 02:06 PM WinRT 7
loading
Tags: SfDataGrid
Vasanth
Asked On April 13, 2015 02:26 PM

Hi,

Is there anyway I can restrict the maximum number of characters allowed to type in GridNumericColumn? I dont want user to type more than 5 characters in GridNumericColumn  column. Please let me know.

Ashok N [Syncfusion]
Replied On April 14, 2015 02:38 PM

Hi Diego,

Thank you for contacting Syncfusion support.

We have analyzed your query and you can achieve this, you need to deriveanew class fromtheGridCellNumericRenderer and overridetheOnInitializeEditElementmethod. Within this method you can the maximum length with help of SfNumericTextBox.MaxLength property. Please refer the below code example.

using Syncfusion.UI.Xaml.ScrollAxis;

using Syncfusion.UI.Xaml.Controls.Input;


public sealed partial class MainPage : Page

{

public MainPage()

{

this.InitializeComponent();

this.sfDataGrid.CellRenderers.Remove("Numeric");

this.sfDataGrid.CellRenderers.Add("Numeric", new GridCellNumericRendererExt());

}

}


public class GridCellNumericRendererExt : GridCellNumericRenderer

{

public override void OnInitializeEditElement(RowColumnIndex rowColumnIndex, SfNumericTextBox uiElement, GridColumn column, object dataContext)

{

uiElement.MaxLength = 5;

base.OnInitializeEditElement(rowColumnIndex, uiElement, column, dataContext);

}

}

Also, you can achieve this by writing style to SfNumericTextBox and set value to MaxLength property within this style because we have load SfNumericTextBox in GridNumericColumn editing mode. Please refer the below code snippet.

xmlns:editors="using:Syncfusion.UI.Xaml.Controls.Input"

<Page.Resources>

<Style TargetType="editors:SfNumericTextBox">

<Setter Property="MaxLength" Value="5"/>

</Style>

</Page.Resources>

Please let us know if you require further assistance.

Thanks,

Ashok


Vasanth
Replied On April 14, 2015 02:42 PM

awesome, thanks!!

Saranya CJ [Syncfusion]
Replied On April 15, 2015 01:50 AM

Hi Diego,

Thank you for your update. Please let us know if you require any other assistance.

Regards,
Saranya

Vasanth
Replied On April 22, 2015 12:41 PM

Hi,
I am using GridCellNumericRendererExt class provided you by Ashok on 4/14 to set MaxLength. There is an issue with the custom renderer, it doesnt rollback to old value when user press esc key for validation issues.

If I dont use the custom renderer, and if validation fails for user input value then pressing esc key rollbacks value.

Vasanth
Replied On April 22, 2015 12:58 PM

One thing to note is, this only happens for indexed properties alone. 

Example: MappingName = "Customers[0].Expense"

Vasanth
Replied On April 22, 2015 01:38 PM

Never mind, I will create an incident for this issue.

Ashok N [Syncfusion]
Replied On April 23, 2015 02:06 PM

Hi Vasanth,

Thank you for your update.

We have analyzed your query and we are able to reproduce the reported “Esc Key does not reset the old value for indexer property when applying the validation” issue. We have updated the details in incident #138209, please refer this incident.

Please let us know if you require further assistance.

Thanks,
Ashok


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;