- Home
- Forum
- ASP.NET Core - EJ 2
- How to set maxlength(Restrict type more than 5 charecter) in editing ejs-grid column edit ? (Urgent)
How to set maxlength(Restrict type more than 5 charecter) in editing ejs-grid column edit ? (Urgent)
<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>
SIGN IN To post a reply.
5 Replies
TS
Thavasianand Sankaranarayanan
Syncfusion Team
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
PR
pradeep
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.
TS
Thavasianand Sankaranarayanan
Syncfusion Team
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.
PR
pradeep
October 9, 2019 05:11 AM UTC
Thanks for its working and thanks for fast support
TS
Thavasianand Sankaranarayanan
Syncfusion Team
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.
SIGN IN To post a reply.
- 5 Replies
- 2 Participants
-
PR pradeep
- Oct 3, 2019 10:01 AM UTC
- Oct 10, 2019 04:11 AM UTC