Recently, I used easyUI framework for an old project and found a problem with id filtering in datagrid filter. When the id entered is too long, the value will automatically change to another value. Because I am not familiar with easyUI, through the source code found that one of the functions dealing with filtering values uses parseFloat([filter Value]), resulting in more than 16 bits of value precision loss, such as search 200000005214716794 will become 200000005214716800. Here is the code for the filter part of the API that calls datagird-Filter:

$('#table').datagrid('enableFilter', [{ field: 'id', hasFilter: true, type: 'numberbox', // Note: precision loss only occurs when the type is numberbox. {onChange(value) {console.log(value) // The value has changed to the value of the lost precision...}}}])Copy the code

** Solution: ** began to think of a solution after finding the reason, which was definitely not recommended to modify the source code of easyUI. The consulting student provided an idea, changing the type value to ‘textbox’, but manually adding the change event listening to the ID input box to realize the logic after the callback. I found the following methods by being familiar with easyUI’s API:

$('#table').datagrid('enableFilter', [{ field: 'id', hasFilter: // If an onChange callback is required, the following textbox event type will be used: Var idFilterCompt = $('#table').datagrid('getFilterComponent', 'id'); Idfiltercompt. textbox({onChange(value) {... }})Copy the code

It is also made for a long time, mainly is not familiar with easyUI, the above method can not change the easyUI source code on the basis of solving the problem of digital screening accuracy.