데이터grid 동적 열

4958 단어 datagrid
var options={}; 
$(function(){ 
    var myNj = 9; 
    //  
    $("#disgrid").datagrid({ 
        type: 'POST', 
        nowrap: false, 
        striped: true, 
        fit:true, 
        width:1024, 
        height:500, 
        url:'', 
        pageSize:30, 
        remoteSort: false, 
        pagination:true, 
        rownumbers:true, 
        singleSelect:true, 
        queryParams:{ 
            nj:myNj, 
            unitType:1 
        } 
    });  
     
    fetchData(myNj); 
}); 
 
function fetchData(nj) { 
    var s = ""; 
    s = "[["; 
    s = s + "{field:'unitname',title:' ',width:160},{field:'practicetime',title:'   ',width:160},{field:'userid',title:'userid',width:120,hidden:'true'}, {field:'serial',title:'serial',width:120,hidden:'true'},{field:'unitid',title:'unitid',width:100,hidden:'true'},"; 
     
    //lu todo   
    if (nj==9) { 
        s = s + "{field:'aipanel_text_exam',title:' ',width:80}, {field:'aipanel_scene_exam',title:' ',width:80}, {field:'aipanel_oral_exam',title:' ',width:80}"; 
        s = s + ",{field:'tatal_score',title:' ',width:60,formatter:function(value,rec) {return paraseIntValue(rec.aipanel_text_exam)+paraseIntValue(rec.aipanel_scene_exam)+paraseIntValue(rec.aipanel_oral_exam);}}"; 
    }else if (nj==7||nj==8){ 
      //.... 
  } 
    s = s + "]]"; 
    options={}; 
    options.url = '/app/search.do'; 
    options.queryParams = { 
        nj:nj, 
        unitType:1 
    }; 
    options.columns = eval(s); 
    //lu   
    options.columns[0].push( 
        { 
            field:'desc',title:' ',width:60, 
            formatter:function(value,rec){ 
                return "<a href=\"javascript:showDescInfo(\'"+rec.serial+"\',\'"+rec.scene_score+" \',\'"+rec.total_score+"\');\"> </a>"; 
            } 
        }    
    ); 
     
    $('#disgrid').datagrid(options); 
    $('#disgrid').datagrid('reload');    
     
}  

다음에서 시작합니다.http://yuncode.net/code/c_5417f4ed435cc82

좋은 웹페이지 즐겨찾기