首页 > 代码库 > js中给easyui的一列添加按钮

js中给easyui的一列添加按钮

 $("#totalTb").datagrid({

 columns: [[
                { field: ‘ENTITY_ACTNAME‘, title: ‘活动名称‘, width: 120, align: "left", halign: ‘center‘ },
                { field: ‘ACT_RATE‘, title: ‘答题中奖率‘, width: 80, align: "right", halign: ‘center‘ },
                { field: ‘ENTITY_START‘, title: ‘开始时间‘, width: 100, align: "center", halign: ‘center‘ },
                { field: ‘ENTITY_END‘, title: ‘结束时间‘, width: 100, align: "center", halign: ‘center‘ },
                { field: ‘ENTITY_NAME‘, title: ‘实物名称‘, width: 100, align: "left", halign: ‘center‘ },
                { field: ‘ENTITY_RATE‘, title: ‘实物中奖率‘, width: 100, align: "right", halign: ‘center‘ },
                { field: ‘ENTITY_NUM‘, title: ‘总数量‘, width: 80, align: "right", halign: ‘center‘ },
                { field: ‘ENTITY_SEND_NUM‘, title: ‘已发放数量‘, width: 100, align: "right", halign: ‘center‘ },
                { field: ‘ENTITY_LAST_NUM‘, title: ‘剩余数量‘, width: 100, align: "right", halign: ‘center‘ },
                {
                    field: ‘OPERATE‘, title: ‘操作‘, width: 100, align: "center", formatter: btnDetailed
                }
        ]],

   });

// 详细按扭
function btnDetailed(value, rowData, rowIndex) {
    if (typeof rowData.ENTITY_NO == "string") {
        return ‘<input type="button" value="http://www.mamicode.com/详细" onclick="clickDetailedEntity( \‘‘ + $.trim(rowData.ENTITY_NO) + ‘\‘);" class="easyui-linkbutton" iconCls="icon-edit" plain="true" style="width:50px;height:20px;" />‘;
    }
}

另:用<button>详细</button>来添加按钮时,当点击按钮时,页面会刷新

用<input  type="button" value="http://www.mamicode.com/详细"/> 点击按钮时不会刷新页面

js中给easyui的一列添加按钮