2016-09-14 21 views
0

我是JTable的新手。我有JSon數據從控制器返回並將數據加載到JTable中。 JSON數據有一個布爾列,說'ShowBold';我想在Showable的JTable中加入整行,但另一方面,我不想在JTable中顯示'ShowBold'。 我正在使用c#,mvc 4和數據在JSon格式如何在jtable中根據列的值粗體地排列一行c#,mvc,json

請任何指導。

我的代碼下:

<script language="JavaScript"> 
    $(document).ready(function() { 
     $('#MyDiv').jtable({ 
      title: 'Client Data', 
      paging: true, 
      pageSize: 10, 
      sorting:true, 
      actions: { listAction: '/Home/getClientData/@Model.ID' }, 
      fields: { ClientID: {title: 'Client ID', width: '15%' }, 
      ClientName: {title: 'Client Name', width: '15%'}, 
      Address: {title: 'Address', width: '15%'}, 
      AmountDue: {title: 'Amount Due', width: '15%'}, 
      ShowBold: {title: 'Show Bold', width: '15%'} 
     }); 

     $('#MyDiv').jtable('reload'); 

    }); 

</script> 

<div id="MyDiv">Client data here.... </div> 
  • 我不想顯示 'ShowBold' JTable中
  • 我想大膽的所有行 'ShowBold'= JTable中真實的。
  • 我的數據是JSon格式。
  • 我使用C#,MVC,實體框架

回答

1

剛剛從JTable中初始化刪除列ShowBold,並在每列的水平在那裏你可以風格你的電池使用顯示功能。

$('#MyDiv').jtable({ 
    title: 'Client Data', 
    paging: true, 
    pageSize: 10, 
    sorting:true, 
    actions: { listAction: '/Home/getClientData/@Model.ID' }, 
    fields: { 
     ClientID: { 
      title: 'Client ID', width: '15%', 
      display: function (data) { 
       if(data.record.ShowBold) 
        return '<b>'+data.record.ClientID+'</b>' 
       else 
        return data.record.ClientID; 
      } 
     }, 
     ClientName: { 
      title: 'Client Name', width: '15%', 
      display: function (data) { 
       if(data.record.ShowBold) 
        return '<b>'+data.record.ClientName+'</b>' 
       else 
        return data.record.ClientName; 
       } 
     }, 
     Address: { 
      title: 'Address', width: '15%', 
      display: function (data) { 
       if(data.record.ShowBold) 
        return '<b>'+data.record.Address+'</b>' 
       else 
        return data.record.Address; 
      } 
     }, 
     AmountDue: { 
      title: 'Amount Due', width: '15%', 
      display: function (data) { 
       if(data.record.ShowBold) 
        return '<b>'+data.record.AmountDue+'</b>' 
       else 
        return data.record.AmountDue; 
      } 
     } 
    } 
}); 

這是ApiReference

+0

謝謝,它的工作... –

相關問題