做网站找那家公司好,做网站的程序员进什么公司好,沈阳网站前端,银川网站建设哪家价格低http://blog.csdn.net/yanghongchang_/article/details/7854156原著 datagrid 可以改变它的view(视图)去显示不同的效果.使用详细视图,datagrid可以显示展开按钮( 或者 -)在数据行的左边,用户可以展开一个行去显示一个附加的详细信息. 查看 Demo 步骤 …http://blog.csdn.net/yanghongchang_/article/details/7854156原著 datagrid 可以改变它的view(视图)去显示不同的效果.使用详细视图,datagrid可以显示展开按钮( 或者 -)在数据行的左边,用户可以展开一个行去显示一个附加的详细信息. 查看 Demo 步骤 1: 创建 DataGrid [html] view plaincopy table iddg stylewidth:500px;height:250px urldata/datagrid_data.json titleDataGrid - Expand Row singleselecttrue fitcolumnstrue thead tr th fielditemid width60Item ID/th th fieldproductid width80Product ID/th th fieldlistprice alignright width70List Price/th th fieldunitcost alignright width70Unit Cost/th th fieldstatus width50 aligncenterStatus/th /tr /thead /table 步骤 2: 为DataGrid设置详细视图 使用详细视图,切记:引入视图script文件在你的页面的头部. [html] view plaincopy script typetext/javascript srchttp://www.jeasyui.com/easyui/datagrid-detailview.js/script [javascript] view plaincopy $(#dg).datagrid({ view: detailview, detailFormatter:function(index,row){ return div idddv- index stylepadding:5px 0/div; }, onExpandRow: function(index,row){ $(#ddv-index).panel({ border:false, cache:false, href:datagrid21_getdetail.php?itemidrow.itemid, onLoad:function(){ $(#dg).datagrid(fixDetailRowHeight,index); } }); $(#dg).datagrid(fixDetailRowHeight,index); } }); 我们定义detailFormatter函数告诉datagrid 如何渲染详细视图,在这种情况下,我们返回一个简单的 div元素,它将充当最为一个详细内容的容器, 注意:详细信息为空,当用户点击展开按钮(),onExpandRow事件将被触发,所以我们可以写一些代码去加载ajax详细内容,最后我们调用fixDetailRowHeight方法去固定行高度,当详细内容加载之后. 步骤 3: 服务器端代码 datagrid21_getdetail.php [php] view plaincopy ?php $itemid $_REQUEST[itemid]; $content file_get_contents(data/datagrid_data.json); $data json_decode($content,true); foreach($data[rows] as $item){ if ($item[itemid] $itemid){ break; } } ? table classdv-table border0 stylewidth:100%; tr td rowspan3 stylewidth:60px ?php echo img src\images/$itemid.gif\ style\height:50px\/; ? /td td classdv-labelItem ID: /td td?php echo $item[itemid];?/td td classdv-labelProduct ID:/td td?php echo $item[productid];?/td /tr tr td classdv-labelList Price: /td td?php echo $item[listprice];?/td td classdv-labelUnit Cost:/td td?php echo $item[unitcost];?/td /tr tr td classdv-labelAttribute: /td td colspan3?php echo $item[attr1];?/td /tr /table 转载于:https://www.cnblogs.com/lacey/p/5884377.html