I did not find a solution on the Internet. I tried it myself and finally gave it a try. I hope it will help you.
The returned json Object in struts2, which stores List <Map <String, Object>
Map contains data such as key: "username" and "id ".
The following code is put into any js function you define:
Var username = $ ("# form_username"). val ();
$ ('# Tt'). datagrid ({
Url: webContext + "/user/queryUserList. action ",
Width: 'auto ',
Height: 'auto ',
Nowrap: false,
IconCls: 'icon-save ',
Striped: true,
Pagination: true,
Rownumbers: true,
PageNumber: 1,
PageSize: 10,
PageList: [5, 10],
QueryParams: {'username': username },
SingleSelect: true,
LoadMsg: 'loading data ......',
Columns :[[
{Field: 'ck ', checkbox: true },
{Field: 'username', title: 'account name', width: 80, align: 'left '},
{Field: 'id', title: 'Role management', align: 'left', width: 80,
// Add a super chain
Formatter: function (value, rowData, rowIndex ){
// The three parameters in the function represent the current field value, the Data Object of the current row, and the row number (the row number starts from 0)
// Alert (rowData. username );
Return "<a href = 'javacrept:; 'onclick = 'mngrol (); '> role management </a> ";
}
}
]
});