|
@{ var valueAccessor = "valueAccessorFn";
}
<ejs-grid id="Grid" dataSource="@ViewBag.datasource" height="500">
<e-grid-columns>
<e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" width="120"></e-grid-column>
<e-grid-column field="CustomerID" headerText="Customer Name" width="120"></e-grid-column>
<e-grid-column field="Freight" headerText="Freight" format="C2" width="140"></e-grid-column>
<e-grid-column field="ShipCountry" headerText="Ship Country" width="150"></e-grid-column>
<e-grid-column field="ShipCity" headerText="Ship City" width="150"></e-grid-column>
<e-grid-column field="Phonenumber" headerText="Phone Number" valueAccessor="valueAccessor" width="150"></e-grid-column>
</e-grid-columns>
</ejs-grid>
<script>
function valueAccessorFn(field, data1, column) {
if (data1[field]) {
return data1[field].replace(/^(\d{3})(\d{3})(\d{4}).*/, "($1) $2 $3");
}
}
</script>
|
|
|
This has provide a solution to me too but when I edit the grid it puts the mask in. I want it to have only what the table has in it
Hi David,
Thanks for your update.
Based on your query, you want to hide the masking when you edit the row. You requirement can be achieved by using the `actionComplete` event of the EJ2 Grid. Where you can set the value from the datasource using the `args.rowData` property to the input element in the edit form .
Please refer the below code example.
|
function actionComplete(args) { if(args.requestType == "beginEdit") { args.form.querySelector('#GridPhonenumber').ej2_instances[0].value = args.rowData['Phonenumber']; } }
|
Please get back to us for further details.
Regards,
Joseph I.