How to view selected multiple rows text as JSON?
How to view selected multiple rows text as JSON?
nzimmer
Posts: 1Questions: 1Answers: 0
So i've been trying to figure out how to view my selected rows as a JSON layout but whenever I try
console.log(JSON.stringify(table.rows('.selected').data()));
It shows me everything in the table instead of the selected values.
<tbody>
<c:forEach var="promotion" items="${Promotion}" varStatus="status">
<tr id="promoteData">
<td class="promotionName" name="promotionName" id="promotionNm">${promotion.getFileName()}</td>
<td class="promotionType" name="promotionType" id="promotionType">${promotion.getFileType()}</td>
<td class="promotionVersion" name="promotionVersion"
id="promotionVer">${promotion.getFileVersion()}</td>
<td class="promotionRevision" name="promotionRevision"
id="promotionRev">${promotion.getFileRevision()}</td>
<td class="promotionDeveloper" name="promotionDeveloper"
id="promotionDev">${promotion.getFileDeveloper()}</td>
<td class="promotionModified" name="promotionModified"
id="promotionMod">${promotion.getFileModified()}</td>
<td class="promotionMode" name="promotionMode" id="promotionMode">${promotion.getFileMode()}</td>
<td class="promotionStatus" name="promotionStatus"
id="promotionStatus">${promotion.getFileStatus()}</td>
<td class="promotionClass" name="promotionClass"
id="promotionClass">${promotion.getFileClass()}</td>
<td class="promotionProject" name="promotionProject"
id="promotionPrj">${promotion.getFileProject()}</td>
</tr>
</c:forEach>
</tbody>
This discussion has been closed.
Answers
Assuming you are using the Select extension you would use the
selected: true
selector-modifier
option:Note the use of
toArray()
to get a plain array rather than a DataTables API instance.Allan