Author Topic: Dynamic Cells  (Read 1557 times)

vasalos

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 2
    • View Profile
Dynamic Cells
« on: January 09, 2018, 07:55:01 pm »
Hello,
I have an extremely dynamic table, in which every cell has separate attributes. My json looks like this for one row of 60 columns:
 row:'2',smio:'0',2:'B1BGV ',blk:'0',3:' ',blk:'0',4:' ',blk:'0',5:' ',blk:'0',6:' ',blk:'0',7:' ',blk:'1',8:' ',blk:'0',9:' ',blk:'0',10:' ',blk:'0',11:' ',blk:'1',12:' ',blk:'0',13:' ',blk:'0',14:' ',blk:'0',15:' ',blk:'1',16:' ',blk:'0',17:' ',blk:'0',18:' ',blk:'0',19:' ',blk:'0',20:' ',blk:'0',21:' ',blk:'0',22:' ',blk:'1',23:' ',blk:'0',24:' ',blk:'0',25:' ',blk:'0',26:' ',blk:'0',27:' ',blk:'0',28:' ',blk:'0',29:' ',blk:'0',30:' ',blk:'0',31:' ',blk:'0',32:' ',blk:'0',33:' ',blk:'0',34:' ',blk:'0',35:' ',blk:'0',36:' ',blk:'0',37:' ',blk:'0',38:' ',blk:'0',39:' ',blk:'0',40:' ',blk:'0',41:' ',blk:'0',42:' ',blk:'0',43:' ',blk:'0',44:' ',blk:'0',45:' ',blk:'0',46:' ',blk:'0',47:' ',blk:'0',48:' ',blk:'0',49:' ',blk:'0',50:' ',blk:'0',51:' ',blk:'0',52:' ',blk:'0',53:' ',blk:'0',54:' ',blk:'0',55:' ',blk:'0',56:' ',blk:'0',57:' ',blk:'0',58:' ',blk:'0',59:' ',blk:'0',60:' ',blk:'0'

My point is each cell which has blk = 1 to render an img as html

render: function(ui) {
               var blk = ui.rowData["blk"];
               if ( blk == 1 ) { return ui.cellData + "<img src=\'images/lock.png\' width=\'12px\'>"; }
               if ( blk == 0 ) {  return ui.cellData;
}

Although this (blk) is not rowData but cellData.
How can I implement this ?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Dynamic Cells
« Reply #1 on: January 10, 2018, 12:40:29 pm »
Your JSON doesn't look properly formatted and most of the values seem to share the same key name "blk" which is incorrect.

Any JSON or a normal js object should have unique key names.

you may need to share a working code example https://plnkr.co/edit/zo6TdOvweAFvWM5JLasV?p=preview
for more clarity about your question.