Adding static values in a column in datatable js

Adding static values in a column in datatable js

NagarajanENagarajanE Posts: 6Questions: 4Answers: 0
edited March 2019 in Free community support

Hi

I have a scenario. i used PNP js and populated 8 column from a sharepoint list. I have binded these columns in to datatable. User wants one more column to be added and that column should contain with static value. That value we are not querying form Sharepoint list.

"aoColumns": [{"data": "ID",
"render": function(mData, type, row, meta){
return meta.row+meta.settings._iDisplayStart+1; 
}
},   
{ "mData":"PRid"  },
{ "mData": "MonitorName.Title" },
**{Form Name} - Static value to be added here**
{ "mData": "BU" },
{ "mData": "Brand" }, 
{ "mData": "MonitoringDt" },
{ "mData": "Created" },
{ "data":"Created",
"render": function(data){
var date= new Date(data);
var month=date.getMonth()+1;
return (month.length > 1 ? month : "0" + month) + "/" + date.getDate() + "/" + date.getFullYear();
}

Please explain me how to add the value

Answers

  • colincolin Posts: 15,215Questions: 1Answers: 2,592

    Hi @NagarajanE ,

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • kthorngrenkthorngren Posts: 20,703Questions: 26Answers: 4,843

    You can try either --option columns.defaultContent or columns.render to render the data. If using render you may need to set columns.data to either null or "".

    Kevin

This discussion has been closed.