-
-
Save michaellouieloria/2942453de1bb051d41e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @jsx React.DOM */ | |
var LopMonHoc = React.createClass({ | |
getInitialState: function(){ | |
return {data: []} | |
}, | |
loadData: function(){ | |
$.ajax({ | |
url: '/daotao/lops', | |
success: function(data){ | |
this.setState({data: data.lops}); | |
}.bind(this) | |
}) | |
}, | |
componentWillMount: function(){ | |
this.loadData(); | |
}, | |
componentDidMount: function(){ | |
var self = this; | |
$('#mytable').dataTable({ | |
"sPaginationType": "bootstrap", | |
"bAutoWidth": false, | |
"bDestroy": true, | |
"fnDrawCallback": function() { | |
self.forceUpdate(); | |
}, | |
}); | |
}, | |
componentDidUpdate: function(){ | |
$('#mytable').dataTable({ | |
"sPaginationType": "bootstrap", | |
"bAutoWidth": false, | |
"bDestroy": true, | |
}); | |
}, | |
render: function(){ | |
var x = this.state.data.map(function(d, index){ | |
return <tr><td>{index+1}</td><td>{d.ma_lop}</td><td>{d.ten_mon_hoc}</td></tr> | |
}); | |
return ( | |
<div class="table-responsive"> | |
<h4>Hello</h4> | |
<table class="table table-bordered" id="mytable"> | |
<thead> | |
<tr class="success"> | |
<td>Stt</td> | |
<td>Mã lớp</td> | |
<td>Tên môn học</td> | |
</tr> | |
</thead> | |
<tbody> | |
{x} | |
</tbody> | |
</table> | |
</div> | |
) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment