0
votes

Ag-grid field should accept only number.

I have tried some code and it works but two arrows button are added.

    field: "TotalQty", headerName: "TOTAL KIT QTY",
    editable: true,

     cellRenderer: params => {
          return '<input type="number" value="TotalQty" class="my-custom-input-class" style="width : 100%">';
        }

I have tried this code and I get expected output but two arrows are added (up and down). How to remove it?

1

1 Answers

0
votes

Try like this

<input (keypress)="onlyNumber($event)" type="text" onpaste="return false" autocomplete="off">

and in your component.ts file

onlyNumber(event): boolean {
const charCode = (event.which) ? event.which : event.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
  return false;
}
return true;

}

Now you can only enter number and there will not be any up down arrow. Cool.