Datatable function in footer

Dear team Webix,
Can you please help me. How can I use in footer custom funtion?
Example:
webix.ui({
rows:[
{ view: “datatable”,
columns:[
{ id: “rank”, header:{ text: “#”, rowspan:2}, width:50, css: “rank”},
{ id: “title”, header:[“movie-title”]},
{ id: “year”, header:[“year”]}, width:80},
{ id: “votes”, header:[“Votes”], width:100, footer:[{content: “mySummColumn”}]},
{ id: “rank”, header:[“Votes2”], width:100, footer:[{content: “mySummColumn”}]},
{ id: “example”, header:[“example”], width:180, footer:[{text: “SUM(votes)/SUM(rank)”}]}
],
autoConfig:true,
data:grid_data,
footer:true}
]
});

In this string:"{ id: “example”, header:[“example”], width:180, footer:[{text: “SUM(votes)/SUM(rank)”}]}"
Snippet: Code Snippet

Thanks in advance!

1 Like

might be useful to someone, one good person helped on stackovewflow
snippet: Code Snippet

webix.ui.datafilter.complexFunction = webix.extend({
refresh: (master, node, value) => {
let sumVotes = 0;
let sumRank = 0;
master.data.order.forEach(id => {
const obj = master.getItem(id);
sumVotes += obj.votes || 0;
sumRank += obj.rank || 0;
});
const result = sumVotes / sumRank;
node.innerHTML =
new Intl.NumberFormat(
‘de-DE’,
{ style: ‘currency’, currency: ‘EUR’ }
).format(Math.round( ( result + Number.EPSILON ) * 100 ) / 100);
}
}, webix.ui.datafilter.summColumn);

1 Like