我正在使用Struts 2.3.7,struts2-jquery-grid-plugin-3.5.0。
<sjg:grid
id="gridtable"
caption="Issue-Summary"
dataType="json"
href="%{remoteurl}"
pager="true"
gridModel="finalGridModel"
rowList="10,15,20"
rowNum="15"
rownumbers="true"
>
<sjg:gridColumn name="issue_id" id="issueId" index="id" title="Issue-ID" formatter="integer" sortable="false"/>
<sjg:gridColumn name="issue_description" index="issue_description" title="Issue-Details" sortable="false"/>
<sjg:gridColumn name="issue_raised_date" index="issue_raised_date" title="Issue-Date" formatter="date" sortable="false"/>
<sjg:gridColumn name="Details" title="Action" formatter="formatLink" sortable="false"/>
<sjg:gridColumn name="issue_status" index="issue_status" title="Current Status" sortable="false"/>
<sjg:gridColumn name="assigned_to" index="issue_status" title="Assigned To" sortable="false"/>
</sjg:grid>
此处我想要在加载jqgrid后禁用特定的行或列,即详细信息。此列是执行某些操作的链接。禁用行基于issue_status。 如果 current_status 为“已分配”,则此行将禁用,否则启用。如何实现这一点,因为我是一个新手,所以我期待一些好的解决方案形成你们。我还添加了截图。
更新:这些是jqgrid执行时生成的html。
<table class="ui-jqgrid-htable" cellspacing="0" cellpadding="0" border="0" aria-labelledby="gbox_gridtable" role="grid" style="width: 925px;">
<thead>
<tr class="ui-jqgrid-labels" role="rowheader">
<th id="gridtable_rn" class="ui-state-default ui-th-column ui-th-ltr" role="columnheader" style="width: 25px;">
<div id="jqgh_gridtable_rn">
<span class="s-ico" style="display:none">
<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 id="gridtable_issue_id" class="ui-state-default ui-th-column ui-th-ltr" role="columnheader" style="width: 150px;">
<th id="gridtable_issue_description" class="ui-state-default ui-th-column ui-th-ltr" role="columnheader" style="width: 150px;">
<th id="gridtable_issue_raised_date" class="ui-state-default ui-th-column ui-th-ltr" role="columnheader" style="width: 150px;">
<th id="gridtable_" class="ui-state-default ui-th-column ui-th-ltr" role="columnheader" style="width: 150px;">
<th id="gridtable_issue_status" class="ui-state-default ui-th-column ui-th-ltr" role="columnheader" style="width: 150px;">
<th id="gridtable_assigned_to" class="ui-state-default ui-th-column ui-th-ltr" role="columnheader" style="width: 150px;">
</tr>
</thead>
</table>
</div>
</div>
答案 0 :(得分:0)
jqgrid有aftersavecell事件..通过使用它,你可以在值设置为网格时调用方法...在方法中你可以检查你的状况并设置你的网格属性......
答案 1 :(得分:0)
我有一个类似的场景,我通过强大的DOM操作jQuery实现。
我使用了MVC的webGrid,它实际上在html中呈现为一个表格,我必须从其一列的值中应用一些逻辑。
首先检查此网格在执行时生成的html元素的类型。 如果它生成一个表格那么这可能会对您有所帮助,
$('table#grid').ready(function () {
MatchColumnValue(5); //Select column node to match value from..starts from 0!
});
这是功能。
function MatchColumnValue(nodeValue) {
$('table#grid tr').each(function () {
$(this).find('td:nth-child(' + nodeValue + '):contains(Assigned)').parent().attr('disabled', true);
});
}