How can the format of number columns in the Filter Menu be set to integer only?

I have a number column in a GridComponent. I have set type="number" in the ColumnDirective.

I am using the following filter settings:

{
  mode: "Immediate",
  immediateModeDelay: 1000,
  type: 'Menu',
}


One of my columns is a number (which is always an integer). When the filter menu is opened and the user types a number into the filter, it always formats the number like "0,000.00" instead of as an integer: "000". Below shows a screenshot.

 


How can I tell the filter modal that this column should not format the number in this way and to leave it as an integer


4 Replies

PS Pavithra Subramaniyam Syncfusion Team July 4, 2022 12:12 PM UTC

Hi Justin Schnurer,


Thanks for contacting Syncfusion support.


By default, the format for the NumericTextBox will be “n2” which is the cause of the behavior. However, you can overwrite this format using the “column.filter.params” property. Please refer to the below code example and API link for more information.


 

<ColumnDirective field="EmployeeID" headerText="Employee ID" width="120"

     textAlign="Right" filter={{ params: { format'N' } }}/>

 


https://ej2.syncfusion.com/react/documentation/api/grid/column/#filter

https://ej2.syncfusion.com/react/documentation/api/numerictextbox/#format


Please get back to us if you need further assistance on this.


Regards,

Pavithra S



JS Justin Schnurer July 5, 2022 12:22 PM UTC

Hi, thanks for the assist.


After applying that format, the filter no longer shows the two decimal points. Is there a way to remove the "," from the number? As shown in the screenshot below, when I type "12345", it is formatted as "12,345". Is there any way to remove the "," from the displayed number so that it is displayed the same way as the grid data cell behind the menu?

 


Thanks



JS Justin Schnurer July 5, 2022 05:30 PM UTC

Also, is it possible to automatically focus on the filter value entry box when the menu is opened?



PS Pavithra Subramaniyam Syncfusion Team July 6, 2022 11:37 AM UTC

Hi Justin Schnurer,


Query#1: Is there any way to remove the "," from the displayed number so that it is displayed the same way as the grid data cell behind the menu?


You can achieve your requirement by setting the custom format for the NumericTextBox as below.


<ColumnDirective field="EmployeeID" headerText="Employee ID" width="120"

     textAlign="Right" filter={{ params: { format'#' } }}/>

 


https://ej2.syncfusion.com/documentation/numerictextbox/formats/#custom-formats


Query#2: is it possible to automatically focus on the filter value entry box when the menu is opened?


You can set focus to the numeric text box by calling the “focus” method inside the “actionComplete” event. Please refer to the below code example for more information.


function actionComplete(e) {

  if (e.requestType == 'filterafteropen' && e.columnName == 'OrderID') {

    setTimeout(() => {

      e.filterModel.dlgDiv.querySelector('.e-numerictextbox').focus();

    });

  }

},

 


Please get back to us if you need further assistance on this.


Regards,

Pavithra S


Loader.
Up arrow icon