基于条件的可扩展子网格
Expandable subgrids based on condition
我有一个带有子网格的网格(祖父母,Parent,child 关系)。
有没有办法根据条件将特定行设置为 expandable/not-expandable?
例如,所有的大parents都有children(parents),有的Parent有children,有的没有.有没有办法让这些没有 children 的 Parents 在 jqgrid 中不可扩展?我正在查看 onSubgridBeforeExpand 属性,但这只会阻止子网格扩展。我不想让用户误以为网格应该是可扩展的,而实际上它不是(单击加号按钮然后什么都没有发生会让我感到困惑)。最坏的情况我可以使用这个属性来显示没有 children 的内容,但我想尽可能避免这种情况。
提前致谢,这是我的 jsp,里面有网格。我不认为 struts.xml 或操作 类 对于此类问题是必需的,但如果您提供可能需要它们的原因,我可以分享它们。
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %>
<s:form id="getJunctionInstance" name="getJunctionInstance" action="populateJI" targets="#gridtable" method="post">
<input hidden="true" name="rpName" id="rpName"/>
</s:form>
<s:form id="getServerHealth" name="getServerHealth" action="populateSH" targets="#gridtable2" method="post">
<input hidden="true" name="jiName" id="jiName"/>
</s:form>
<script>
$.subscribe("getJunctionInstance",function(event){
let row_id = event.originalEvent.row_id;
document.forms['getJunctionInstance'].elements['rpName'].value = row_id;
//document.forms['getJunctionInstance'].submit();
//Don't submit the form, as it is submitted when onSubGridRowExpanded for gridtable is called
});
$.subscribe("getServerHealth",function(event) {
let row_id = event.originalEvent.row_id;
document.forms['getServerHealth'].elements['jiName'].value = row_id;
});
</script>
<s:url var="remoteurl" action="updateRP"/>
<s:url var="junctionInstanceJson" action="updateJIJson"/>
<s:url var="serverHealthJson" action="updateSHJson"/>
<sjg:grid
id="gridtable"
caption="Reverse Proxy List"
dataType="json"
href="%{remoteurl}"
pager="true"
gridModel="proxies"
rowList="10,15,20"
rowNum="20"
rownumbers="true"
onSubGridRowExpanded="getJunctionInstance"
height="600"
width="900"
loadonce="true"
>
<sjg:grid
id="gridtable2"
caption="Junction Instance List"
dataType="json"
subGridUrl="%{junctionInstanceJson}"
pager="true"
gridModel="junctionInstance"
formIds="getJunctionInstance"
reloadTopics="getJunctionInstance"
rowList="10,15,20"
rowNum="20"
rownumbers="false"
onSubGridRowExpanded="getServerHealth"
width="700"
loadonce="true"
>
<sjg:grid
id="gridtable3"
caption="Server Health List"
dataType="json"
subGridUrl="%{serverHealthJson}"
pager="true"
gridModel="serverInstance"
formIds="getServerHealth"
reloadTopics="getServerHealth"
rowList="10,15,20"
rowNum="20"
rownumbers="false"
width="500"
loadonce="true"
>
<sjg:gridColumn name="name" index="name" title="Name" key="true" hidden="true" sortable="false"/>
<sjg:gridColumn name="label" index="label" title="Label" sortable="true"/>
<sjg:gridColumn name="health" index="health" title="Health" formatter="integer" sortable="true"/>
</sjg:grid>
<sjg:gridColumn name="name" index="name" title="Name" key="true" hidden="true" sortable="false"/>
<sjg:gridColumn name="label" index="label" title="Label" sortable="true"/>
<sjg:gridColumn name="health" index="health" title="Health" formatter="integer" sortable="true"/>
</sjg:grid>
<sjg:gridColumn name="name" key="true" index="name" title="Name" hidden="true" sortable="false"/>
<sjg:gridColumn name="label" index="label" title="Label" sortable="true"/>
<sjg:gridColumn name="health" index="health" title="Health" formatter="integer" sortable="true"/>
</sjg:grid>
Does anyone know if this type of conditioning is possible with jqgrid?
好吧,花了一段时间,但在今天偶然发现之后,我终于弄明白了。我为每个网格添加了一个 onCompleteTopics 选项,每个网格都有不同的 formSubmission。然后我使用 javascript 函数订阅那些表单提交,并执行逻辑。我利用 event.originalEvent 获取了检索 row_ids 的信息,这些信息符合我不想要子网格的标准,post 中提出的方法负责剩下的工作!向那个人致敬!
我有一个带有子网格的网格(祖父母,Parent,child 关系)。
有没有办法根据条件将特定行设置为 expandable/not-expandable?
例如,所有的大parents都有children(parents),有的Parent有children,有的没有.有没有办法让这些没有 children 的 Parents 在 jqgrid 中不可扩展?我正在查看 onSubgridBeforeExpand 属性,但这只会阻止子网格扩展。我不想让用户误以为网格应该是可扩展的,而实际上它不是(单击加号按钮然后什么都没有发生会让我感到困惑)。最坏的情况我可以使用这个属性来显示没有 children 的内容,但我想尽可能避免这种情况。
提前致谢,这是我的 jsp,里面有网格。我不认为 struts.xml 或操作 类 对于此类问题是必需的,但如果您提供可能需要它们的原因,我可以分享它们。
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %>
<s:form id="getJunctionInstance" name="getJunctionInstance" action="populateJI" targets="#gridtable" method="post">
<input hidden="true" name="rpName" id="rpName"/>
</s:form>
<s:form id="getServerHealth" name="getServerHealth" action="populateSH" targets="#gridtable2" method="post">
<input hidden="true" name="jiName" id="jiName"/>
</s:form>
<script>
$.subscribe("getJunctionInstance",function(event){
let row_id = event.originalEvent.row_id;
document.forms['getJunctionInstance'].elements['rpName'].value = row_id;
//document.forms['getJunctionInstance'].submit();
//Don't submit the form, as it is submitted when onSubGridRowExpanded for gridtable is called
});
$.subscribe("getServerHealth",function(event) {
let row_id = event.originalEvent.row_id;
document.forms['getServerHealth'].elements['jiName'].value = row_id;
});
</script>
<s:url var="remoteurl" action="updateRP"/>
<s:url var="junctionInstanceJson" action="updateJIJson"/>
<s:url var="serverHealthJson" action="updateSHJson"/>
<sjg:grid
id="gridtable"
caption="Reverse Proxy List"
dataType="json"
href="%{remoteurl}"
pager="true"
gridModel="proxies"
rowList="10,15,20"
rowNum="20"
rownumbers="true"
onSubGridRowExpanded="getJunctionInstance"
height="600"
width="900"
loadonce="true"
>
<sjg:grid
id="gridtable2"
caption="Junction Instance List"
dataType="json"
subGridUrl="%{junctionInstanceJson}"
pager="true"
gridModel="junctionInstance"
formIds="getJunctionInstance"
reloadTopics="getJunctionInstance"
rowList="10,15,20"
rowNum="20"
rownumbers="false"
onSubGridRowExpanded="getServerHealth"
width="700"
loadonce="true"
>
<sjg:grid
id="gridtable3"
caption="Server Health List"
dataType="json"
subGridUrl="%{serverHealthJson}"
pager="true"
gridModel="serverInstance"
formIds="getServerHealth"
reloadTopics="getServerHealth"
rowList="10,15,20"
rowNum="20"
rownumbers="false"
width="500"
loadonce="true"
>
<sjg:gridColumn name="name" index="name" title="Name" key="true" hidden="true" sortable="false"/>
<sjg:gridColumn name="label" index="label" title="Label" sortable="true"/>
<sjg:gridColumn name="health" index="health" title="Health" formatter="integer" sortable="true"/>
</sjg:grid>
<sjg:gridColumn name="name" index="name" title="Name" key="true" hidden="true" sortable="false"/>
<sjg:gridColumn name="label" index="label" title="Label" sortable="true"/>
<sjg:gridColumn name="health" index="health" title="Health" formatter="integer" sortable="true"/>
</sjg:grid>
<sjg:gridColumn name="name" key="true" index="name" title="Name" hidden="true" sortable="false"/>
<sjg:gridColumn name="label" index="label" title="Label" sortable="true"/>
<sjg:gridColumn name="health" index="health" title="Health" formatter="integer" sortable="true"/>
</sjg:grid>
Does anyone know if this type of conditioning is possible with jqgrid?
好吧,花了一段时间,但在今天