How the DataGrid control column in Easyui binds properties in an object

Source: Internet
Author: User

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:

  1. Public class Manager implements Java.io.Serializable {
  2. private Integer ID;
  3. private role role;
  4. private String LoginName;
  5. private String password;
  6. private int status;
  7. private Date lastdate;
  8. private Date createat;
  9. private String remarks;
  10. //Omit get and set
  11. }

Where role is an object

  1. <table id="Manager_datagrid" >
  2. <thead>
  3. <tr>
  4. <th data-options="field: ' LoginName '" > Account </th>
  5. <th data-options="field: ' Role ', Formatter:managerroleformat" > Jobs </th>
  6. <th data-options="field: ' Createat '" > Creation time </th>
  7. <th data-options="field: ' Lastdate '" > Last login Time </th>
  8. <th data-options="field: ' Status ', Formatter:managerstatusformat" > Status </th>
  9. <th data-options="field: ' Remarks '" > Remarks </th>
  10. </tr>
  11. </thead>
  12. </table>

    1. function Managerroleformat (val,row) {
    2. if (val) return val.rolename;
    3. Else return "";
    4. }

    1. function Managerstatusformat (val,row) {
    2. Switch (val) {
    3. Case 0: return ' deactivate ';
    4. case 1: return ' normal ';
    5. default: return ';
    6. }
    7. }

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.