2013-06-10 5 views
0

dwr 호출은 임의의 수의 특정 열을 포함 할 데이터 집합을 반환합니다. 예를 들어 이름, ID, 주소. 주소는 첫 번째 레코드의 경우 address1, address2, 두 번째 데이터의 경우 address1, address2, address3과 같이 1,2,3이 될 수 있습니다. 내 질문은 jqgrid 동적 열 이름을 만드는 방법입니다.동적 데이터 로딩을 사용하는 동적 jqgrid

DataHandler.fetch(function(data){ 
resultSet = data; 
jQuery("#table1").jqGrid({ 
datatype : "local", 
    data : resultSet, 
    height : 250, 
    width : 978, 
    sortable : false, 
    ignoreCase : true, 
    sortorder : "desc", 
    colNames : ['Email Date/Time','User Name', 'Department'] //want to make this dynamic 
    colModel : [ { 
    name : 'mailedOn', 
    index : 'mailedOn', 
    width : '18%', 
    align : 'center', 
    }, { 
    name : 'userName', 
index : 'userName', 
width : '18%', 
    align : 'left', 
    sorttype : 'text', 
}], 
     rowList:[10,20,30], 
     pager : '#pager', 
     rowNum : 10, 
     altRows : true, 
     altclass: "myclass", 
    viewrecords : true 
     }); 
    }); 

어떤 도움 ??

답변

0

일부 수정 된 (알려진) 개수의 열이 있고 열 머리글을 동적으로 변경해야하는 경우 (colNames 변경) the answer에서 솔루션을 읽고 the demo을 시도하는 것이 좋습니다. 질문은 "중복"으로 표시되고 내 답변에는 현재 투표가 없으므로 검색 중에 답변을 찾을 수 없습니다.

내 제안의 주요 아이디어는 c1, c2 등과 같은 일부 일반 열 이름을 사용하며 beforeProcessing 내부에서 동적으로 열 헤더를 수정합니다. 같은 방법으로 colModel (formatter, formatoptions, editoptions 등으로 설정) 항목의 속성을 수정할 수도 있지만 현재이 작업을 수행 할 필요가없는 것으로 보입니다.

+0

당신이 제안한 것을 다시 시도하고 되돌릴 수 있습니다. 고맙습니다 – sahana

관련 문제