+ Start a Discussion
mobile vistexmobile vistex 

can we add td dynamically based on a condition

Hi can we add a column dynamically based on a condition ......

i want to add <td> not apex:column
HI ,

You can do this using javascript/jqyery or with any other javascript framework.

Use "insertRow" and "insertCell" javascript functions to add row/column dynamicaly.
<!DOCTYPE html>
table, td {
    border: 1px solid black;

<p>Click the button to add a new row at the first position of the table and then add cells and content.</p>

<table id="myTable">
    <td>Row1 cell1</td>
    <td>Row1 cell2</td>
    <td>Row2 cell1</td>
    <td>Row2 cell2</td>
    <td>Row3 cell1</td>
    <td>Row3 cell2</td>

<button onclick="myFunction()">Try it</button>

function myFunction() {
    var table = document.getElementById("myTable");
    var row = table.insertRow(0);
    var cell1 = row.insertCell(0);
    var cell2 = row.insertCell(1);
    cell1.innerHTML = "NEW CELL1";
    cell2.innerHTML = "NEW CELL2";

Let us know if it helps you.
Hi ,
Here is jquery code to do same.
var $row = $('<tr>'+
if(obj.Type=='Error') {
    $row.append('<td>'+ obj.ErrorCode+'</td>');
$('table> tbody:last').append($row);