Progressbar max value not fixed in advance

Progressbar max value not fixed in advance

PhilouPhilou Posts: 24Questions: 4Answers: 0

I did integrate the progress bar in the Datatables. However, the max value is a fix number in my exemple.
This max value should be variable regarding the max value in the column.
Is there a way to calculate first the max value of the column and then render the Datatable using the calculated max value when rendering it ?

{
targets:3,
title:'Progress',
defaultContent:'',
data:'fieldData.Salary',
type:'num',
searchable:true,
visible:true,
orderable:true,
render:function(data, type, row, meta) {return '<progress value="' + data + '"max="150000"type="progressbar" ></progress>';},
},

https://jsbin.com/puxarebuca/edit?html,output

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Answer ✓

    You could access the main data array in the rendering function to calculate the max value, but that would be very inefficient as render can be called a four or more times per cell.

    Depending on how you are loading the data, I would suggest performing the max calculation up front - e.g. if you are using Ajax loaded data use xhr and store it in a variable your rendering function can access.

    Allan

  • PhilouPhilou Posts: 24Questions: 4Answers: 0

    Well I am using Filemaker database and implementing datatables in it.
    Like you advise, I calculate the max value before rendering the table, and it works.
    Thanks !

Sign In or Register to comment.