The DataGrid control in Easyui is one of the controls that we often use,
However, the DataGrid control does not support object property binding when it is bound to display columns.
The model is as follows:
- Public class Manager implements Java.io.Serializable {
- private Integer ID;
- private role role;
- private String LoginName;
- private String password;
- private int status;
- private Date lastdate;
- private Date createat;
- private String remarks;
- //Omit get and set
- }
Where role is an object
- <table id="Manager_datagrid" >
- <thead>
- <tr>
- <th data-options="field: ' LoginName '" > Account </th>
- <th data-options="field: ' Role ', Formatter:managerroleformat" > Jobs </th>
- <th data-options="field: ' Createat '" > Creation time </th>
- <th data-options="field: ' Lastdate '" > Last login Time </th>
- <th data-options="field: ' Status ', Formatter:managerstatusformat" > Status </th>
- <th data-options="field: ' Remarks '" > Remarks </th>
- </tr>
- </thead>
- </table>
- function Managerroleformat (val,row) {
- if (val) return val.rolename;
- Else return "";
- }
- function Managerstatusformat (val,row) {
- Switch (val) {
- Case 0: return ' deactivate ';
- case 1: return ' normal ';
- default: return ';
- }
- }
This allows us to implement the binding of object properties by Easyui The formatter function we provide.
How the DataGrid control column in Easyui binds properties in an object