When binding data with the DataGrid of Easyui today, the data provided by the background is the entity class type, where the property B of an entity Class A is another entity class B type, and the foreground needs to display B's attribute C, which is tragic, the front desk can not be directly bound, then the brain a turn, Think of the column property of the DataGrid Formatter,formatter provides row, so we can specify it in the formatter.
So ~
functionDgdevice_datagrid () {$ (' #dgDevice '). DataGrid ({URL:' Devicelist.ashx?action=getdevices ', toolbar:' #tb1 ', Width:540, Singleselect:true, Remotesort:true, Sortname:' Saledate ', SortOrder:' Desc ', Rownumbers:true, Columns: [[{title:' Device ID ', field: ' DeviceID ', width:190, align: ' center '}, {title:' Factory date ', field: ' Exfactorydate ', width:110, align: ' center ', Formatter:function(val) {returnFormatDate (Val, "Yyyy-mm-dd"); }}, {title:' Date of Sale ', field: ' Saledate ', width:110, align: ' center ', Formatter:function(val) {returnFormatDate (Val, "Yyyy-mm-dd"); }}, {title:' Account ', field: ' AccountName ', width:80, align: ' center ', Formatter:function(value, row, index) {returnrow. Account.accountname; }}]], OnSelect:function(RowIndex, RowData) {Dgsensor_datagrid (Rowdata.deviceid); } }); }
Perfect ~
Easyui DataGrid Binding Properties of JSON object properties