Skip to content
Advertisement

How to add attributes to TD/TR from new row of bootstrap-table?

Currently I have project using bootstrap-table. I have problem when add new row with attribute. To insert new row I used code below:

JavaScript

I want to add attribute also to the new row. I am currently used jQuery like below:

JavaScript

But that’s attribute will lost after I insert/append new row again. After I sort the table my attributes will lost too. actually how to add attribute to new row of bootstrap-table?

Advertisement

Answer

I already read all documentation and I can not found how to do that. But today, after I experiment use console.log to check what object/data inside every row in bootstrap-table I solved my problem with code below:

JavaScript

_data is data attribute for the row (example <tr data-id="val">)

_action_data is data attribute for the column which named action(exampled result <td data-tag="val">)

Advertisement