單擊EasyUI的datagrid行時不選中


單擊EasyUI的datagrid行時不選中,行背景色不變,點擊選擇框checkbox時選中該行 

核心代碼:

 $("#msgList").datagrid({
        url: "../Ajax/MessageAjax.ashx",
        queryParams://每次請求的參數
            {
                cmd: 'msgList',
                strWhere: strWhere
            },
        fitColumns: true,
        pagination: true,   //允許分頁
        rownumbers: true,   //行號
        singleSelect: false,//true只能選擇一行
        nowrap: true,//如果為true,則在同一行中顯示數據。設置為true可以提高加載性能。
        striped: true, //奇偶行是否區分
        //autoRowHeight:true,//定義設置行的高度,根據該行的內容。設置為false可以提高負載性能。
        pageSize: 20,       //設置默認每頁30條記錄
        checkOnSelect: true,
        collapsible: true,
        loadMsg: '數據加載中……',
        pageList: [10, 20, 50, 100, 500, 1000],//可自定義每頁顯示多少條記錄
        columns: [[
            {
                field: "row",
                checkbox: true
            
            },
            
        {
            field: "m_title",
            title: "標題",
            align: "center",
            width: "900"
        },
         {
             field: "m_date",
             title: "日期",
             align: "center",
             width: "150"
         },
          {
                 field: "m_id",
                 title: "操作",
                 align: "center",
                 width: "150",
                 //styler: function (value, row, index) {
                 //    return 'background-color:gray;'
                 //},
                 formatter: function (value, row, index) {
                     return '<a  id="blue" href="javascript:void(0)"  onclick="MsgRetail(' + row.m_id + ')" >詳情</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a  id="blue" href="javascript:void(0)"  onclick="EditMsg(' + row.m_id + ')" >編輯</a> ';
                 }
             }
         
        ]],
        onLoadSuccess: function (data) {
            var s = $("#msgList").datagrid('getPanel');
          var rows = s.find('tr.datagrid-row');                       //注意這一行
          var rows1 = s.find('tr.datagrid-row td[field!=row]');
          rows1.unbind('click').bind('click',function(e){
                 return false;

          });
        },


    });

 

注意:  var rows = s.find('tr.datagrid-row');  

      row要和

          {
                field: "row",
                checkbox: true         
            },

       field中的鍵保持一致

 效果圖:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM