추가 버튼을 사용하여 그리드를 서브 그리드로 표시하는 데 문제가 있습니다. jqgrid 별도의 Button으로 서브 그리드로 그리드 표시
subGridRowExpanded:
이벤트에서 코드를 복사하려고했습니다. 그러나 Grid는 subGridRowExpanded가 시작되기 전에 더러운 것을하고 있습니다. 왼쪽의 + 버튼을 사용하면 눈금이 올바르게 표시됩니다. 이제 생성 된 버튼을 누르면 하위 그리드도 다시로드됩니다. 처음에 함수를 중지시키기 위해 경고를 사용했고 subGridRowExpanded 앞에 테이블이 삽입 된 것을 보았습니다.
그래서 이벤트 전에 함수가 누락 된 것 같습니다. 어쩌면 내 작업에 잘못된 이벤트를 사용하고있을 수 있습니다.
다음은 기본 코드의 코드입니다. 버튼을 생성하는 기능 :
gridComplete: function(){
var ids = jQuery("#task").jqGrid('getDataIDs');
var running_task_ids=get_running_task_id_ajax();
for(var i=0;i < ids.length;i++){
var cl = ids[i];
start = "<input style='height:22px;width:50px;' type='button' value='Start' onclick=\"start_stop_task('"+cl+"','start');\" />";
stop = "<input style='height:22px;width:50px;' type='button' value='Stop' onclick=\"start_stop_task('"+cl+"','stop');\" />";
se = "<input style='height:22px;width:50px;' type='button' value='Save' onclick=\"jQuery('#task').saveRow('"+cl+"');\" />";
//ce = "<input style='height:22px;width:20px;' type='button' value='C' onclick=\"jQuery('#task').restoreRow('"+cl+"');\" />";
co = "<input style='height:22px;width:70px;' type='button' value='Comment' onclick=\"foobar('task_"+cl+"',"+cl+");\" />";
}
}
(단지 아 격자 예를 들어 그리드에서 복사)를 호출 기능 :
function foobar(subgrid_id, row_id) {
// klappt noch nicht!
alert(subgrid_id+":"+row_id);
// we pass two parameters
// subgrid_id is a id of the div tag created whitin a table data
// the id of this elemenet is a combination of the "sg_" + id of the row
// the row_id is the id of the row
// If we wan to pass additinal parameters to the url we can use
// a method getRowData(row_id) - which returns associative array in type name-value
// here we can easy construct the flowing
var subgrid_table_id, pager_id;
subgrid_table_id = subgrid_id+"_t";
pager_id = "p_"+subgrid_table_id;
$("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table><div id='"+pager_id+"' class='scroll'></div>");
jQuery("#"+subgrid_table_id).jqGrid({
url:"ajax/listtasktime/id/"+row_id,
onSelectRow:
function(id){
if(id && id!==lastsel2){
jQuery('#'+subgrid_table_id).jqGrid('restoreRow',lastsel2);
//jQuery('#task').jqGrid('editRow',id,true,pickdates_e);
jQuery('#'+subgrid_table_id).jqGrid('editRow',id,true);
lastsel2=id; }
},
datatype: "xml",
colNames: ['ID','START','END', 'Time'],
colModel: [
{name:"ID",index:"num",width:80,key:true},
{name:"START",index:"item",width:180,editable: true},
{name:"END",index:"qty",width:180,align:"right",editable: true},
{name:"TIME",index:"qty",width:180,align:"right"}
],
rowNum:20,
pager: pager_id,
sortname: 'num',
sortorder: "asc",
height: '100%'
});
jQuery("#"+subgrid_table_id).jqGrid('navGrid',"#"+pager_id,{edit:false,add:false,del:false})
alert("done");
}