鍍金池/ 問答/UI  HTML/ 關(guān)于easyui里面使用bootstrap進(jìn)度條的問題

關(guān)于easyui里面使用bootstrap進(jìn)度條的問題

代碼如下,現(xiàn)在的問題是怎么動(dòng)態(tài)設(shè)置類名為progress-bar的div的寬度,設(shè)置為value值,我這樣寫貌似沒用。

$(function() {
    $('#list').datagrid({
        url : '${pageContext.request.contextPath}/getDataSum.action',
        rownumbers:true,
        singleSelect:true,
        height:'',
        pagination : true,
        fitColumns :true,
        remoteSort : false,
        sortOrder: 'desc',
        sortName: 'test',
        title : '',
        border:false,
        queryParams: {
            
        },
        columns:[[
                    {field:'region',title:'區(qū)域',width:200,align:'center',
                        formatter : function(value,row,index){
                            var rowz = row.region;
                            if(rowz==null){
                                return "蘇州大市";
                            }else{
                                return value;
                            }
                        }
                    },
                    {field:'test',title:'年度任務(wù)批次',width:200,align:'center'},
                    {field:'y',title:'實(shí)時(shí)抽檢總數(shù)',width:200,align:'center',sortable:true},
                    {field:'t',title:'合格率',width:200,align:'center',sortable:true},
                    {field:'i',title:'年度抽檢進(jìn)度',width:200,align:'center',sortable:true,
                        formatter : cell},
        ]]
    });

}); 
function cell(value,row,index){
    return '<div class="progress"><div class="progress-bar" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" >'+value+'</div></div>';
    $('.progress-bar').css('width',value);
}
回答
編輯回答
夕顏
function cell(value,row,index){
        if(row.test>=row.y){
            return '<div class="progress progress-striped active"><div class="progress-bar progress-bar-success" style="width:'+value+'" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" >'+value+'</div></div>';
        }else{
            return '<div class="progress progress-striped active"><div class="progress-bar progress-bar-info" style="width:100%" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" >'+value+'</div></div>';
        }
    }
2017年12月22日 23:52