Tabulator processing ajax data before load

  javascript, tabulator

I need help if it is possible to modify table data before load into table in Tabulator library.
I need to convert decimal value of (8 poles)DIP switch to separate 8 bits and load it to table.
I have data in json format like this:

[
{"id":1, "name":"DIP1", "value":15},
{"id":2, "name":"DIP2", "value":75}
]

and I would like format data to this (for decimal value 15):

[{"id":1, "name":"DIP1", "sw1":0,"sw2":0,"sw3":0,"sw4":0,"sw5":1,"sw6":1,"sw7":1,"sw8":1,}]

I know how to extract each bit in c:

 var sw1 = bitRead( value, 7 );
 var sw2 = bitRead( value, 6 );
 var sw3 = bitRead( value, 5 );
 var sw4 = bitRead( value, 4 );
 var sw5 = bitRead( value, 3 );
 var sw6 = bitRead( value, 2 );
 var sw7 = bitRead( value, 1 );
 var sw8 = bitRead( value, 0 );

but I dont know how to do this when data are loaded into table using ajax.

Can somebody help how to do it please?

I am newbie and I cant help myself.

Thank you!

Source: Ask Javascript Questions

LEAVE A COMMENT