ag-grid number filter is not working when the field value is rounded - filter

The requirement as follows; The data from backend is stored in row data and passed to ag-grid. The numeric fields in the row data needs to be rounded to 2 digits or more based on the business need. I need to provide numeric filter that needs to filter based on rounded values.
I have attached a sample code in plunker https://plnkr.co/edit/zlNhlPmmFC2GfLfS.
{ field: 'exp',
filter: "agNumberColumnFilter",
cellRenderer: params => {
if (params.value) {
return Number(parseFloat(params.value).toFixed(2)).toLocaleString("en");
}},
filterValueGetter: params => {
if (params.data.exp) {
return Number(parseFloat(params.data.exp).toFixed(2)).toLocaleString("en");
}}
},
For example, the experience column is received as 3.765. It needs to be displayed as 3.77. I have used cellRenderer to achieve the same. It is working fine. The next step is filter needs to work when the user type in 3.77. But it is working when the user is typing the original value 3.765. So I am trying to achieve this using filterValueGetter and round the values. It is not working. I have tried options with valuegetter and filter api and it is not working. Appreciate a solution without modifying the actual json and format it in the grid using the available API

Related

Filebeat Script Processor Event.Get All Fields In Log

I am looking to get all of the fields in a record in filebeat using the Script processor and perform an action on them. Using the event.Get() from the script processor, it says, "Get a value from the event (either a scalar or an object). If the key does not exist null is returned. If no key is provided then an object containing all fields is returned."
https://www.elastic.co/guide/en/beats/filebeat/current/processor-script.html
Therefore, my question is, what would I do to ensure that no key is provided to get an object that contains all of the fields are returned?
The event.Get() field will provide the top level fields. To look through these top level fields, use a for loop like:
- script:
lang: javascript
id: get_fields
source: >
function process(event) {
var a = event.Get();
for (var key in a) {
if(event.Get(key) == ""){
event.Delete(key);
}
}
}
I am unsure how to do this for nested fields in this way nor have I tried to extend it to nested fields, but this is how it works for now.

How to iterate through a hidden column in jquery data table

I have a data table that has a hidden column. I want to set the values of that column to a java script array. (Note: I want to get the values that belong to the current page only). If I use a search filter, I want the values of the current page of the search result.
I've tried like this.
$('#datatbl').DataTable().rows({filter: 'applied'}).every(function () {
var row = this.data();
arr.push(row[0]);
});
But,this code gives all values from all the pages. Please help....
Try adding page:'current' in selector.
$('#datatbl').DataTable().rows({filter: 'applied', page:'current'})

kendo ui grid datasource how to update filters to send all filter values

I have a grid with filter header in every columns. When the user type something in a filter, the datasource send a request to the server to get the data. This is fine when is only one column filter. The problem is when the user after obtain the filtered results needs to filter by another column, and without to remove the previous filter type something in other column filter. In this second situation i need to send all filter values and not only the second filter.
You don't mention what language you use. I assume you do it with javascript.
So you can use the code below.
var grid = $('#ClientsGrid').data("kendoGrid");
grid.dataSource.filter({
field: "client_status",
operator: "eq",
value: "2"
If you need to clear all filters, you can use
var grid =('#ClientsGrid').data("kendoGrid");
grid.dataSource.filter({});

How to show an array (multiple values) in a webix datatable column

I need to show multiple values (rank and vote) together separated by space as key:value in a webix datatable cell from the following structure :
id2: [{"rank":2, "vote":50}, {"rank":3, "vote":10}]
I want to show only the first element of this above array.
My snippet is here : https://webix.com/snippet/ca50874d
I am not able to figure out how to show these two values together in one cell.
Please help.
Thanks.
To show multiple values in the cell, or if you want to format the value according to you, you just need to use to template for that cell:
While specifying column configuration, you can specify the template for that particular column like below:
template:function(obj) {
}
This template will be called for each row, and obj contains the row object.
For your example you can specify the template like below:
template:function(obj) {
return obj.column1 +':' + obj.column2;
}
I further tried and could figure out the answer on my own. To show the first element of that array object, the 'map' attribute has to be used as below:
{ id:"id2", header:"Rank", width:80, map:"#id2[0].rank# : #id2[0].vote# "}
The working snippet for the same is here : https://webix.com/snippet/928bab77

how to correctly render referenced entities in list when I have objects instead of numberic ids?

right now in order for the list to render properly I need to have this kind of data passed in:
row = {
id: value,
name: value,
height: value,
categories: [1,2,3,4]
}
how can I adapt the code so that a list works with this kind of data?
row = {
id: value,
name: value,
height: value,
categories: [{id: "1"},{id: "2"},{id: "3"},{id: "4"}]
}
when I try to do that it seems that it applies JSON.stringify to the objects so it is trying to find category with id [Object object]
I would to avoid a per case conversion of data as I do now..
it seems that I cannot do anything in my restClient since the stringify was already applied
I have the same issue when I fetch just one data row e.g in Edit or Create.. categories ReferenceArrayInput is not populated when categories contains objects
Have you tried using format?
https://marmelab.com/admin-on-rest/Inputs.html#transforming-input-value-tofrom-record
Might help transform your input value. Then you can use format() to change values back to the format your API expects.
If this does not work then you will have to probably create a custom component out of ReferenceArrayInput.

Resources