jqGrid细节备注—jqGrid中获取subGrid的标题栏对象

jqGrid中获取subGrid的标题栏对象
jqGrid中subGrid的使用方法也很简单,设置subGrid:true,并且配置subGridRowExpanded,该属性是一个函数,在这个函数实现对subGrid的绘制,
思路也很简单,就是在当前的格子中插入table和div,然后在是通常的jqGrid的写法。大多数参数的配置和jqGrid的常规配置一致。
在要获取标题栏的时候,通过打印html(),发现,jqGrid构造的表格还是很复杂的。它的标题栏不是想象中的首行,而是另外一个独立的table,因此,要获得它也蛮复杂的,通过一系列parent()方法。下面是一段例子
subGridRowExpanded: function(subgrid_id, row_id) {
// we pass two parameters
// subgrid_id is a id of the div tag created within a table
// the row_id is the id of the row
// If we want to pass additional parameters to the url we can use
// the method getRowData(row_id) - which returns associative array in type name-value
// here we can easy construct the following
var subgrid_table_id,subgrid_pager_id;
subgrid_table_id = subgrid_id+"_t";
subgrid_pager_id = subgrid_id+"_div";
jQuery("#"+subgrid_id).append("<table id='"+subgrid_table_id+"' class='scroll'></table>");
jQuery("#"+subgrid_id).append("<div id='"+subgrid_pager_id+"' class='scroll'></div>");
jQuery("#"+subgrid_table_id).jqGrid({
url:"./AjaxHandler/jqGrid_Jsondata_Content.ashx?id="+row_id,
datatype: "json",
jsonReader: {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
id: "rowid"
},
colNames: ["内容", "作者", "时间"],
colModel: [
{ name: "content", index: "content", 550, sorttype: "string",sortable:false },
{ name: "author", index: "author", 80, sorttype: "string", formatter: "string",sortable:false },
{ name: "datetime", index: "datetime", 80, sorttype: "string", formatter: "string",sortable:false}
],
rowNum: 15,
height: "100%",
viewrecords: true,
pager:"#"+subgrid_pager_id,
loadComplete:function(){
//隐藏第一行标题栏
var p= $("#"+subgrid_table_id).parent().parent().parent()
p=$(p).find("table").first().hide();
}
   });
}
表格html如下:
<DIV style="DISPLAY: none" class="ui-jqgrid-titlebar ui-widget-header ui-corner-top ui-helper-clearfix"><A style="RIGHT: 0px" class="ui-jqgrid-titlebar-close HeaderButton" role=link href="javascript:void(0)"><SPAN class="ui-icon ui-icon-circle-triangle-n"></SPAN></A><SPAN class=ui-jqgrid-title></SPAN></DIV>
<DIV style=" 725px" class="ui-state-default ui-jqgrid-hdiv" loading="true">
<DIV class=ui-jqgrid-hbox>
< TABLE style=" 725px" class=ui-jqgrid-htable role=grid aria-labelledby=gbox_listdata_jqtr88_t border=0 cellSpacing=0 cellPadding=0>
<THEAD>
<TR class=ui-jqgrid-labels role=rowheader>
<TH style=" 550px" id=listdata_jqtr88_t_content class="ui-state-default ui-th-column ui-th-ltr" role=columnheader><SPAN style="CURSOR: col-resize" class="ui-jqgrid-resize ui-jqgrid-resize-ltr">&nbsp;</SPAN>
<DIV id=jqgh_listdata_jqtr88_t_content class="ui-th-div-ie ui-jqgrid-sortable">内容<SPAN style="DISPLAY: none" class=s-ico><SPAN class="ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr" sort="asc"></SPAN><SPAN class="ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr" sort="desc"></SPAN></SPAN></DIV></TH>
<TH style=" 80px" id=listdata_jqtr88_t_author class="ui-state-default ui-th-column ui-th-ltr" role=columnheader><SPAN style="CURSOR: col-resize" class="ui-jqgrid-resize ui-jqgrid-resize-ltr">&nbsp;</SPAN>
<DIV id=jqgh_listdata_jqtr88_t_author class="ui-th-div-ie ui-jqgrid-sortable">作者<SPAN style="DISPLAY: none" class=s-ico><SPAN class="ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr" sort="asc"></SPAN><SPAN class="ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr" sort="desc"></SPAN></SPAN></DIV></TH>
<TH style=" 80px" id=listdata_jqtr88_t_datetime class="ui-state-default ui-th-column ui-th-ltr" role=columnheader><SPAN style="CURSOR: col-resize" class="ui-jqgrid-resize ui-jqgrid-resize-ltr">&nbsp;</SPAN>
<DIV id=jqgh_listdata_jqtr88_t_datetime class="ui-th-div-ie ui-jqgrid-sortable">时间<SPAN style="DISPLAY: none" class=s-ico><SPAN class="ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr" sort="asc"></SPAN><SPAN class="ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr" sort="desc"></SPAN></SPAN></DIV></TH></TR></THEAD></ TABLE ></DIV></DIV>
<DIV style=" 725px; HEIGHT: 100%" class=ui-jqgrid-bdiv>
<DIV style="POSITION: relative">
<DIV></DIV>
< TABLE style=" 725px" id=listdata_jqtr88_t class="  ui-jqgrid-btable" role=grid tabIndex=1 aria-labelledby=gbox_listdata_jqtr88_t aria-multiselectable=false border=0 cellSpacing=0 cellPadding=0>
<TBODY>
<TR style="HEIGHT: auto" class=jqgfirstrow role=row>
<TD style=" 550px; HEIGHT: 0px" role=gridcell></TD>
<TD style=" 80px; HEIGHT: 0px" role=gridcell></TD>
<TD style=" 80px; HEIGHT: 0px" role=gridcell></TD></TR></TBODY></ TABLE ></DIV></DIV>

你可能感兴趣的:(style,div,normal,标题栏,face)