私は、フロントエンドにAngularjsを、私のアプリケーションのバックエンドとしてspring mvcを使用しています。私はレコードを表示するためにデータテーブルを使用しています。私が直面している問題は、時々作業するデータテーブルであり、時にはそうではありません。jQueryのデータ型が動作しない
編集、削除、または動的操作を実行した後、データテーブルのページング、フィルタリング、検索などの形状が失われます。データはありますが、レコードは存在しませんが、ページネーションのないレコードも表示されます。
私はdraw()
とreload
メソッドをスクリプトで試しましたが、何も動作していないようです。 htmlページのローディングCSSやJSファイルの私のために は、これは私がすべてを試みたスクリプトである。この
<html lang="en" data-ng-app="adminApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" type="text/css" media="screen" href="resources/front/css/bootstrap.css">
<link rel="stylesheet" type="text/css" media="screen" href="resources/front/css/Custom-Style.css">
<link rel="stylesheet" type="text/css" media="screen" href="resources/front/font-awesome-4.0.3/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" media="screen" href="resources/front/font-awesome-4.0.3/css/font-awesome.css">
<link rel="stylesheet" type="text/css" media="screen" href="resources/front/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" media="screen" ref="resources/front/css/responsive.dataTables.min.css">
<link rel="stylesheet" href="resources/angular/angulars-datetime-picker.css" />
<link rel="stylesheet" href="resources/front/css/spinner.css">
<script src="resources/front/js/jquery-1.12.4.js" type="text/javascript"></script>
<script src="resources/front/js/bootstrap.js" type="text/javascript"></script>
<script type="text/javascript" src="resources/front/js/Custom-js.js"></script>
<script src="resources/front/js/jquery.dataTables.js" type="text/javascript"></script>
<script type="text/javascript" src="resources/front/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="resources/front/js/dataTables.responsive.min.js"></script>
</head>
</html>
のようなものです。私はこれをhead
タグの中に入れました。上記のすべてのコードをすべてのHTMLファイルに入れました。ここで
<script>
$(document).ready(function() {
$('#example').DataTable();
});
</script>
私はここの表に
<div class="TableBox">
<table id="example" class="display responsive nowrap"
cellspacing="0" width="100%" >
<thead>
<tr role="row">
<th class="sorting_asc" tabindex="0" aria-controls="example"
rowspan="1" colspan="1" aria-sort="ascending" aria-label="" >
SlNo
</th>
<th class="sorting_asc" tabindex="0" aria-controls="example"
rowspan="1" colspan="1" aria-sort="ascending"
aria-label="">Name</th>
</tr>
</thead>
<tbody>
<tr role="row" class="even" data-ng-repeat="student in students">
<td>{{$index + 1}}</td>
<td>{{student.studentName}}
</td>
</tr>
</tbody>
</table>
</div>
データを表示するためのNGリピートを使用していますがここでは私のAngularController.js
$scope.getAllStudents = function()
{
AdminStudentService.getAllStudents().then(function(response)
{
$scope.students=response.data;
});
}
でどのようなことは、私の更新方法
$scope.updateStudent = function(student)
{
$scope.editstudentForm.$submitted= true;
if($scope.editstudentForm.$valid)
{
AdminStudentService.updateStudent(student).then(function(response)
{
if(response.data=="success")
{
$scope.editstudentForm.$submitted= false;
$window.scrollTo(0,0);
$scope.student = {};
$scope.getAllStudents();
$scope.successmessage1="Student Details Updated!;
$timeout(function()
{
$scope.closeeditStudent();
$scope.successmessage1="";
}, 1500);
}
});
}
}
です
私はsomを見逃していますか?スクリプトの中に何かか、何かを追加する必要がありますか?
私は質問が更新されました。もし何かが可能であれば、私は同じ編集を提案することができます。
いくつかのフィールドを変更した後、最新のデータでデータテーブルを再初期化するメソッドを呼び出していますか?基本的に、新しいデータでデータテーブルを再生成するには、ng-initメソッドを再度呼び出さなければなりません。 –
私はメソッドを呼び出していません。私は上記のようにスクリプトを配置しています。私はinitメソッドを呼び出す必要がありますか?任意のフィールドの更新を行った後、更新されるとすぐにAngularController.js.AsのgetAllStudents()メソッドを呼び出していますので、新たに更新されたフィールドが表示されます。ページネーションとフィルタリングのプロパティは消えます –
関連する問題