<script type= "Text/javascript" >
function Tagposition () {
$ (' #easyTables '). Tabs (' Select ', ' output mode ');
var rows = $ (' #dgTag '). DataGrid (' GetRows ');//Gets the data row of the current page
var ary = new Array ();
var ary = "";
for (var i = 0; i < rows.length; i++) {
ary + = rows[i][' id ']+ ",";
}
Ary=ary.substring (0,ary.length-1);
$.ajax ({
URL: '.. /.. /modelfilter/position ',
Type: ' POST ',
data:{"ary": ary},
Success:function (Result) {
Console.log (ary);
}
});
}
Move on
function Datagridrowmove (isUp) {
var rows=$ (' #dgTag '). DataGrid (' GetRows ');
var rowlength=rows.length;
var selectrow=$ (' #dgTag '). DataGrid (' getselected ');
var rowindex=$ (' #dgTag '). DataGrid (' Getrowindex ', selectrow);
if (rowindex==0) {
$.messager.alert (' Hint ', ' top row cannot move up! ', ' warning ');
}else{
$ (' #dgTag '). DataGrid (' DeleteRow ', rowIndex);//delete a row
rowindex--;
$ (' #dgTag '). DataGrid (' InsertRow ', {
Index:rowindex,
Row:selectrow
});
$ (' #dgTag '). DataGrid (' SelectRow ', rowIndex);
}
}
Move Down
function DatagridRowMove1 (isUp) {
var rows=$ (' #dgTag '). DataGrid (' GetRows ');
var rowlength=rows.length;
var selectrow=$ (' #dgTag '). DataGrid (' getselected ');
var rowindex=$ (' #dgTag '). DataGrid (' Getrowindex ', selectrow);
$ (' #dgTag '). DataGrid (' DeleteRow ', rowIndex);//delete a row
rowindex++;
$ (' #dgTag '). DataGrid (' InsertRow ', {
Index:rowindex,
Row:selectrow
});
$ (' #dgTag '). DataGrid (' SelectRow ', rowIndex);
if (rowindex>=rowlength) {
$.messager.alert (' Hint ', ' last line cannot be moved down! ', ' warning ');
}
}
</script>
Add onclick= "tagposition ()"
Background Save moved data
@RequestMapping (value = "/position", method = Requestmethod.post)
@ResponseBody
public void position (String ary) {
if (ary!=null &&!ary.equals ("")) {
Modeltag model = new Modeltag ();
string[] arr = Ary.split (",");
try {
for (int i = 0; i < arr.length; i++) {
Model.setid (Integer.parseint (arr[i));
Model.settagposition (i + 1);
Modelfiltermanager.updatatagencryption (model);
}
/*model.setid (9600);
Model.setmoduleid ("2017021316419558");
Model.settagposition (1);
Modelfiltermanager.updatatagencryption (model); */
SYSTEM.OUT.PRINTLN ("Controller " + ary);
} catch (Exception e) {
E.printstacktrace ();
}
}
}
This article comes from reprint
JS table row moves up and down