easyui DataGrid checkbox is checked according to the data passed from the background

 
[javascript]  view plain copy  
  1. function loadMessage() {  
  2.     $('#pressure').datagrid({  
  3.         height: 500,  
  4.         url: '/Home/RealtimeData',  
  5.         method: 'POST',  
  6.         //queryParams: { 'id': OBJECTID },  
  7.         idField: 'ID',  
  8.         striped: true,  
  9.         fitColumns: true,  
  10.         singleSelect: false,  
  11.         rownumbers: true,  
  12.         pagination: false,  
  13.         nowrap: false,  
  14.         pageSize: 10,  
  15.         pageList: [10, 20, 50, 100, 150, 200],  
  16.         showFooter:  true ,  
  17.         columns: [[  
  18.             { field: 'ck', checkbox: true },  
  19.             { field: 'ElementId', title: 'ElementId', width: 180, align: 'left' },  
  20.             { field: 'Label', title: 'Label', width: 180, align: 'left' },  
  21.             { field: 'Meter_Name', title: 'Meter_Name', width: 180, align: 'left' },  
  22.             { field: 'Station_Un', title: 'Station_Un', width: 180, align: 'left' },  
  23.             { field: 'MeasureAre', title: 'MeasureAre', width: 180, align: 'left' },  
  24.             { field: 'DistrictAr', title: 'DistrictAr', width: 180, align: 'left' },  
  25.             { field: 'Explain', title: 'Explain', width: 180, align: 'left' }  
  26.         ]],  
  27.         onBeforeLoad: function (param) {  
  28.   
  29.         },  
  30.         onLoadSuccess: function (data) {  
  31.             if (data) {  
  32.                 $.each(data.rows, function (index, item) {  
  33.                     if (item.Display == 1) {  
  34.                         $('#pressure').datagrid('checkRow', index);  
  35.                     }  
  36.                 });  
  37.             }  
  38.         },  
  39.         onLoadError: function () {  
  40.   
  41.         },  
  42.         onClickCell: function (rowIndex, field, value) {  
  43.   
  44.         }  
  45.     });  
  46. }  

Add a loop event in the onLoadSuccess event, if the display shows one, set the current row to the selected state.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326166337&siteId=291194637