Bootstrap Table

by jimkennelly

HTML

<link rel="stylesheet" href="https://rawgit.com/wenzhixin/bootstrap-table/master/src/bootstrap-table.css">
<script src="https://rawgit.com/wenzhixin/bootstrap-table/master/src/bootstrap-table.js"></script>
<button id="button" class="btn btn-default">
    get description for row
</button>
<table id="table" >
    <thead>
    <tr>
        <th data-field="name" data-sortable="true">Name</th>
        <th data-field="stargazers_count" data-sortable="true">Stars</th>
        <th data-field="forks_count" data-sortable="true">Forks</th>
        <th data-field="description">Description</th>
    </tr>
    </thead>
</table>

JavaScript

var data = [
    {
    		"id": "1",
        "name": "bootstrap-table",
        "stargazers_count": "526",
        "forks_count": "122",
        "description": "An extended Bootstrap table with radio, checkbox, sort, pagination, and other added features. (supports twitter bootstrap v2 and v3) "
    },
  
];

$(function () {
    $('#table').bootstrapTable({
        data: data,
        uniqueId: 'id',
        rowStyle: function(row, index) {
            return {
                classes: [row.state]
            };
        }
    });
    $('#button').click(function () {
    	  var id = prompt("enter id");
    		var n =  $('#table').bootstrapTable('getRowByUniqueId', id);
        alert('Description for id:' + id + ' is --->' + n.description);
        //debugger;
        
    
    });
});