javascriptfunctiondatatablefooterwebix

How can i use custom function in datatable footer? Webix, javascript


trying to learn datatable in webix. An example of what I wanted to get in the column "example".

webix.ui.datafilter.mySummColumn = webix.extend({
    refresh:function(master, node, value){
        var result = 0;
        master.mapCells(null, value.columnId, null, 1, function(value){
            value = value * 1;
            if (!isNaN(value))
                result += value;
            return value;
        });
        node.innerHTML = new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(Math.round( ( result + Number.EPSILON ) * 100 ) / 100);
    }
}, webix.ui.datafilter.summColumn);

webix.ui({
  rows:[
    { view:"datatable", 
     columns:[
        { id:"rank",    header:{ text:"#", rowspan:2}, width:50, css:"rank"},
        { id:"title",   header:["Film 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:[{content:"SUM(votes)/SUM(rank)"}]}
    ],
     autoConfig:true, 
     data:grid_data, 
     footer:true}
  ]
});

This string:"{ id: “example”, header:[“example”], width:180, footer:[{content: “SUM(votes)/SUM(rank)”}]}"

Thanks in advance!


Solution

  • You cannot make composition of functions, unfortunately. You will have to create a custom function, just like you did with mySummColumn. https://snippet.webix.com/cfjaiins