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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to set maxlength(Restrict type more than 5 charecter) in editing ejs-grid column edit ? (Urgent)

Thread ID:

Created:

Updated:

Platform:

Replies:

148075 Oct 3,2019 10:01 AM UTC Oct 10,2019 04:11 AM UTC ASP.NET Core - EJ 2 5
loading
Tags: DataGrid
pradeep
Asked On October 3, 2019 10:01 AM UTC

<e-grid-column field="strVehicleTariffName" type="string" editType="TextBox"  validationRules="@(new { required=true})" headerText="Tariff Name" width="232" ></e-grid-column>

                                        <e-grid-column field="tintVehTariffType" type="number" editType="dropdownedit" validationRules="@(new { required=true})" foreignKeyField="tintVehTariffType" foreignKeyValue="strVehTariffType" dataSource="ViewBag.VehTariffTypeList" edit="new {@params = DropDownList }" headerText="Type" width="112"></e-grid-column>
                                        <e-grid-column field="tintVehTariffACNonAC" type="number" editType="dropdownedit" validationRules="@(new { required=true})" foreignKeyField="tintVehTariffACNonAC" foreignKeyValue="strVehTariffACNonAC" dataSource="ViewBag.VehTariffACNonACList" edit="new {@params = DropDownList }" headerText="A/C" width="92"></e-grid-column>

Thavasianand Sankaranarayanan [Syncfusion]
Replied On October 4, 2019 11:40 AM UTC

Hi Pradeep, 

Greetings from Syncfusion support. 

We can achieve your requirement “set max length for string type column in Grid for validation”. By using the maxLength property of validationRules in columns API. 

Refer the below code example. 

[Index.cshtml] 

<ejs-grid id="Grid" dataSource="ViewBag.dataSource"  toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" })" allowPaging="true"> 
        <e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true" newRowPosition="Top"></e-grid-editSettings> 
        <e-grid-columns> 
            <e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" validationRules="@(new { required=true, number=true})" width="140"></e-grid-column> 
 
            <e-grid-column field="CustomerID" headerText="Customer Name" validationRules="@(new { required=true, maxLength=5})" width="150"></e-grid-column> 
             
 
             ---- 
 
 
        </e-grid-columns> 
    </ejs-grid> 



Regards, 
Thavasianand S 


pradeep
Replied On October 4, 2019 11:53 AM UTC

I already use but i want to restrict user only can enter 5 character only.user can not type more than 5 character in  it.

Thavasianand Sankaranarayanan [Syncfusion]
Replied On October 7, 2019 08:52 AM UTC

Hi Pradeep, 
 
We suggest you to use the below solution to resolve this problem. Here we have used the actionComplete event to restrict the characters to enter in the input box. Please refer the below code example for more information. 
 
Index.cshtml 
 
<ejs-grid id="Grid" allowPaging="true" load="onLoad" actionComplete="ActionComplete" toolbar="@(new List<string>() {"Add", "Edit", "Update", "Delete" })">​ 
... 
<script> 
    function ActionComplete(args) { 
        if (args.requestType == "beginEdit") { 
            var inputElement = document.getElementById(this.element.id + "CustomerID"); 
            inputElement.setAttribute('maxlength', '5'); 
        } 
    } 
</script> 
 
 
 
  
Refer the help documentation. 
 
 
Regards, 
Thavasianand S.



pradeep
Replied On October 9, 2019 05:11 AM UTC

Thanks for its working and thanks for fast support

Thavasianand Sankaranarayanan [Syncfusion]
Replied On October 10, 2019 04:11 AM UTC

Hi Pradeep, 
 
Thanks for your update. 
 
We are happy that the problem has been resolved at your end. 
 
Regards, 
Thavasianand S.  


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon