0

How to append 2 jsons to the same datatable, like:

$('#divInWhichTableIsRendered').puidatatable({ 
                  columns: [  
                      {field:'f1', headerText: 'f1', sortable:true},  
                      {field:'f2', headerText: 'f2', sortable:true}, 
                      {field:'f3', headerText: 'f3', sortable:true}, 
                      {field:'f4', headerText: 'f4', sortable:true},
                      {field:'f5', headerText: 'f5', sortable:true} 
                  ],  
                  datasource: ourJson1,
              });

$('#divInWhichTableIsRendered').puidatatable({ 
                  columns: [  
                      {field:'f1', headerText: 'f1', sortable:true},  
                      {field:'f2', headerText: 'f2', sortable:true}, 
                      {field:'f3', headerText: 'f3', sortable:true}, 
                      {field:'f4', headerText: 'f4', sortable:true},
                      {field:'f5', headerText: 'f5', sortable:true} 
                  ],  
                  datasource: ourJson2,
              });

Currently if we do so, the table is populated with ourJson2 & the ourJson1 is over written - which is what we DON'T want.

In fact, I have to highlight some specific rows, based on a certain condition (depends on the Json data), but i am unable to do so. If I apply class to the column..then it gets applied to every row.

Pii
  • 35
  • 6

1 Answers1

0

First question: As there is no 'addOption' for puidatatable you'll need to merge the two datasources (ourJson1 and ourJson2) before you initiate the puidatatable.

What you are doing right now is to initiate the puidatatable twice - once with the ourJson1 and after that with ourJson2. The second puidatatable overrides (obviously) the first one.

Second question (you should always ask just one question, if you need to ask another one, create a new question):

Provide the code you execute and we'll be able to help you. We don't know what you have tried and where you have failed.

Manuel
  • 3,828
  • 6
  • 33
  • 48
  • I want to highlight certain rows depending on a condition (from the json data ) . Can we do so ? – Pii Apr 08 '15 at 06:51
  • If you have a separate question, ask a new question. The system is simple: Ask 1 question, get 1 answer. Don't put ask 5 question at once, that's confusing if people just answer e.g., 2 of 5. – Manuel Apr 08 '15 at 07:09